Error help
Hey there, been at this for a while now and for the life of me cannot figure out why it isn't passing these tests, any help would be appreciated.
GitHub: https://github.com/Fallexs/CKK.Logic/tree/master/CKK.Logic
Errors: https://pastebin.com/CQdTkbG4
GitHub
CKK.Logic/CKK.Logic at master ยท Fallexs/CKK.Logic
Contribute to Fallexs/CKK.Logic development by creating an account on GitHub.
Pastebin
Output CKK.Logic -> /home/codegrade/student/CKK.Logic/bin/Debug/ne...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
69 Replies
The errors are quite clear
Well, warnings, really
They are clear and tell me whats wrong but every time I try to edit it to fix it, it adds more or doesn't pass
Uh, why is your
UnitTest1.cs
a git diff and not a normal C# file...?also, please add a
.gitignore
file with default .NET settings in itAlso, this file
/home/codegrade/student/CKK.Tests/StoreTests.cs
just straight up isn't in your repodotnet new gitignore
Those tests were for something old and aren't used anymore, just forgot to get rid of them.
OH the code grade tests aren't in the repo
They are separated in a VM in codegrade that are tested against my code
:d
The first error seems to be about this one, yes
The test expects
null
but is given a valuelinq query syntax, bad formatting, returning inside a foreach...
no early returns
And
PascalCase
local vars, don't forget Sorry I've just been going off what I've been taught if there's a better way to query or return I'd appreciate any help
Let me try this and see if it fixes the error
also
not sure about that select? it seems to extract the product, not the shoppingcartitem
Is there an integrated console in Virtual Studio where I run this or just any terminal inside the folder path
select
is in the original query so ยฏ\_(ใ)_/ยฏthe root folder of your project
I never used query syntax thoug, so idk
nah thats just confusing naming. there is no select.
As in where the .sln is located?
sure
bet gimme 2 seconds to update it
see if it fixes the error
dunno if it will tbh, but it does pretty much the same as you have now
you might want to use
SingleOrDefault
instead of FirstOrDefault
, its technically more correct.Pastebin
Output CKK.Logic -> /home/codegrade/student/CKK.Logic/bin/Debug/ne...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
It fixed one of them
but I don't understand the others, are the methods not already doing that?
well without the code for the tests we can only guess what its actually testing
Yea thats the big struggle i've been having with most of this
Its trial and error to find what niche thing it wants me to do
I can't tell if is not returning null or if its testing an item to find that should be returning null
Was expecting null but was given a value.
tells me that you are returning a value when it was.. expecting a null
but the name is weird
ShouldReturnEmptyStoreItem
is not the same as ShouldReturnNull
if you ask me.
but thats what the error seems to indicatreFailed CKK.Tests.ShoppingCartTests.RemoveProduct_ShouldRemoveIfQuantityIsNegative [< 1 ms]
, meanwhile, should be about removing items when RemoveProduct()
method is given a negative amountah yes
I'm assuming its because the other error Isn't removing the item correctly and returning something?
so, I cleaned up your removeproduct but have not "optimized" it yet
we can easily see that you throw an exception on
quant < 0
nowbut it checks for Should I not be returning a new item here?
Seems like you're throwing on negative value, but the test expects it to be a valid value?
In the instructions I was told
It was super confusing because it wants me to throw exceptions in the setter of properties and also in the methods so most of the time it wouldn't even reach the method exception because it caught it in the property setter.
if im understanding correctly
Ill try this and report ๐ซก
no
read what I said
nothing has been changed functionality wise
I just cleaned it up to make it readable
ah
I saw that you removed the linq query and thought it was a possible fix
It wasn't removed
I just rewrote it with method syntax
which is preferred by 99% of C# developers
Ohh sorry im unfamiliar with that way
I'd suggest you learn it.
its considered standard ๐
hm
Appreciate the help, it does look way better than my other query lol
If the product does not exist, throw ProductDoesNotExistExceptionthis can be interpreted in two ways one: no product exists with that
id
exists in the list of known products
two: no cart item with a product with that id
exists in this cartIn my Store.cs I have pretty much the exact same Method but it doesnt remove the item from the list when the quantity is below 0 so the product should always exist.
well my point stands
since we cant see the tests, we dont know what they are testing for
either of those interpretations are valid if you ask me
Yea im stumped tbh idk if its like 1. List is wrong 2. Remove method is wrong 3. Product is wrong
because im definitely checking for positive Quantity and removing if not
are you sure returning an empty cart item is correct?
seems odd that it can even exist if you ask me
it has no product associated with it, for one
this is how I'd re-write your remove method
but in general I think your cart has issues
why is the list of cart items called
Products
when it contains cart items, not products?๐คทโโ๏ธ You're asking the same person who wrote the grading errors, half of this project I was taught something, told to implement it, then told to rewrite all of it with major inconsistencies once I was taught something new.
Your guess is as good as mine
๐ฆ
AddProduct(): If the quantity given is less than or equal to 0, throw InventoryItemStockTooLowExceptionwait what
You should see the earlier versions of this lol my Shopping cart was a Method that had 3 spots and checked for null on first spot and if it wasn't then moved to the second one and so on, only holding 3 items.
that exception indicates that your cart should be updating the inventory?!
The instructions and what im told to put are so confusing
I'll probably delete all of this in the next assignment and do it another way anyway
yeah don't envy your situation, having to code with poor specifications and against hidden tests is not fun
It's so weird because they teach me like the bottom barrel way to do something which is cool if i'm just starting out and learning it but then to have to delete and redo everything because oh wow heres a better way we held out on you because who knows
It's like why not just teach me something and then keep building on it so I have a path im following and understand
well as someone who has taught a lot of people how to code... its not possible to jump directly from beginner to "modern code" in most cases
Still returning same errors
I mean yeah I'm not fixing any issues
I just re-wrote your code
I dont even know what the issues are, because again, I don't know what the test is testing
Yea but thats also what I mean like, teaching beginner stuff is fine but have a way to flow or lead into a better way to do it and build upon it instead of just ok now forget that way because we've upgraded you to a whole new different path and 100 new syntax
I mean, yeah, but also.. thats hard ๐
if you've only learned
if
statements, you can do quite a bit, its just not the ideal way
as you see here with your code vs mine
but at the same time, its very important to understand if
really really well
building something that looks and behaves like a real project as early as possible is an admirable goal, even if it means you have to unlearn some stuff later on
its a tradeoff for sure, and the specifications for this project seems to be very poorI guess it wouldn't be as bad without these god awful instructions and ambiguous grading params because idk if im doing anything correctly and end up rethinking everything for oh maybe if i do this it'll work because I don't fully understand what its asking
these god awful instructions and ambiguous grading paramsI think you hit the nail on the head. I love automated test suites to verify that the code is correct, but here its really hard to guess what they mean
Yea any tests against my code user made or automated are super helpful, I just wish it would tell me if a certain line went wrong, had better error names, or showed the tests being run against it
I don't suppose you can ask your teacher to clarify the instructions regarding where the confusion is?
I did yesterday with no response and again 3 hours ago with no response ๐
:/
Appreciate the help anyway we got a couple errors to go away lol ๐
yeah sure, np.
try to look at how my methods work and how ๐
for example, any
if
statement that contains a return statement doesnt need an else
you can just add the "else" code below the if
your loops also dont make much sense, you only needed them becasue your queries were fetching multiple items instead of a single, but its clear from the method signature that a single item (or null) was expected