Krzak
Krzak
CC#
Created by Krzak on 7/4/2024 in #help
Learning how to test API with NUnit and Nsubstitute
I'm trying to work out how to do that, starting with a method that fetches all of the data from the database and saves it to a list (it's async, seems like it's causing a lot of trouble). It's a really tough nut to crack, I'm reading stackoverflow, tried the documentation for NSubstitute but there isn't much there tbh. I'm trying to notice a pattern in the code fragments provided but I don't know. I wasn't able to do much on my own because of conflicting information. I'm pretty sure I got the next part wrong but: The documentation says that for the substitutions I should use an interface, not a class to avoid some weird behaviour. Ok, I can make that to substitue the database context class but the controller constructor doesn't want an interface, only the context class (I'm fully aware this might be a design mistake on my side because I'm the one that made all that lol). It seems that the substitutes need to have their behaviour specified manually but I don't understand that either. One person has told me that I don't really need to test crud if it's not complicated but apart from the API I also have a web app and that definitely needs testing (also implementing error handling) but I wanted to learn on something less intimidating first.
22 replies
CC#
Created by Krzak on 7/4/2023 in #help
❔ ✅ Manipulating JSON
I'm using MediaWiki API to receive information about movies. From that I need to extract movie titles and page IDs to use them to get their specific sites and extract when the movie was made, the initial response doesn't contain this information. Finally, the title and year will be displayed in a list on a web page. That's quite a lot of information to process so I got a bit lost in there 🤔
15 replies
CC#
Created by Krzak on 6/28/2023 in #help
✅ App advice before starting writing anything
I tried to make the app twice but got stuck/tangled into a huge mess so I'm redoing it again. Maybe the problem is with planning, I don't know. I've never done any similar things before so that's a factor too. It's just for a portfolio but tbh it'd be of use to me as well. I'm afraid it's too ambitious but I refuse to make a 1000th to-do list haha The most basic idea is that the app searches for voice actors basing on movie titles. So when I'm watching a movie and I recognize the person, I can find out where else were they present. I'm going to use a MediaWiki API, it's neat. I'm not sure if it's up to date but I'm assuming I'll be using MVC architecture. The wiki's results come in JSON so classes for it can be generated by VisualStudio, this will go into the Model part. Next I have to deserialize it into something usable, that's the Controller part I guess? Viewing is in View, that's pretty straightforward. So far I had the most issue with connecting View to Controller. I used <input> in a <form> element, is this correct? I know it's hard to say anything without code but I deleted it all 😅 I'll be posting updates but I'd like to get something to build on first. It's weird that any tutorials are either old or difficult to understand, is it normal?
24 replies
CC#
Created by Krzak on 3/14/2023 in #help
❔ Quitting to main menu in console app
The app is used to monitor a habit with saving the data to a database. The user has to insert a date and one number (for example how many glasses of water they drank that day) and I wanted to make it so writing 0 in the console would result in quitting to main menu, but with the way I did it first, it kind of "opens" another menu in that menu? I read that usually these kinds of apps are done with a "while" loop but they don't mention going back, only closing. How to untangle this mess? (I'll post code snippets in a second)
54 replies
CC#
Created by Krzak on 2/20/2023 in #help
❔ MongoDB modified console output
I want one of the console app's functions to be displaying all documents from a collection but not in a "raw" way (quotation marks, brackets etc.) that simply iterating does. I'd like to do something similar to inerpolation so there's a message that I can insert values into or can define how the document's fields are displayed myself. I'm looking into cursors and projection but projection only "cuts out" what isn't needed, according to a query, the raw database "look" is still there. Is it even possible to do what I want with mongodb? Using pretty() still leaves the brackets and quotations. Or maybe it's in "deserializing BSON territory"? It's my first time using any database.
2 replies