September 4, 2018
Summer is over, and I'm trying to remind myself, that I have a blog. I have almost finished a post, how I used Android for a week (spoiler alert: it's fine, but I don't like it), but for now I want to throw couple things, that appear during my joby-job job:
- If you trying to test EF model functionality, but dont want to make in-memory database or build complex cases, you can create Mock object for tested class as this:
public Mock<ClassNameToTest> ClassNameToTestMock = new Mock<ClassNameToTest>() {CallBase = true};
This will call original methods and properties of this class, if you will not Setup-ed it by other values. Very usefull, when one of the properties, that I needed for test was a protected setter and it can be only set by EF, which I didnt want to bother for simple test.
- I have created small code snippet to easily paste mocks into test class. Sometimes it's not working, but I can say the same about all another parts of Visual studio.
- Extension methods in C# exist and implemented more transarent (static methods with this as a parameter), than in Swift. Cant wait to find a excuse to write one.
- Task, that can be used for job interview: given ordered array of numbers (A), and some parameter value (B). You need to write code, that will select only first objects from A, sum of which is not greater, than B. Should be impemented in O(n) and in linq.
It's very simple thing, actually and I have ended with this solution. Much more difficult were to conclude two enormous queries into one simple function.
Next entry →
← Prev entry