Posts

Showing posts with the label Properties

Can I Loop Through A Javascript Object In Reverse Order?

Answer : Javascript objects don't have a guaranteed inherent order, so there doesn't exist a "reverse" order. 4.3.3 Object An object is a member of the type Object. It is an unordered collection of properties each of which contains a primitive value, object, or function. A function stored in a property of an object is called a method. Browsers do seem to return the properties in the same order they were added to the object, but since this is not standard, you probably shouldn't rely on this behavior. A simple function that calls a function for each property in reverse order as that given by the browser's for..in, is this: // f is a function that has the obj as 'this' and the property name as first parameter function reverseForIn(obj, f) { var arr = []; for (var key in obj) { // add hasOwnPropertyCheck if needed arr.push(key); } for (var i=arr.length-1; i>=0; i--) { f.call(obj, arr[i]); } } //usage reverseFo...

Check If A Property Was Set - Using Moq

Answer : I think VerifySet is the right approach. It would look something like this: //Arrange var mock = new Mock<IDRepository>(); var mockRequest = new Mock<Request>(); // TODO: set some expectations here var dManager = new DManager(mock.Object); //Act dManager.Create(mockRequest.Object); //Assert mockRequest.VerifySet(x => x.Status = Status.Submitted); I believe in your case, it blows up because you haven't set up your Request mock to handle the set operation on Status. One easy way to do that is using SetupAllProperties , like so: //Arrange var mock = new Mock<IDRepository>(); var mockRequest = new Mock<Request>(); mockRequest.SetupAllProperties(); I think you should use strict behavior by default, then you can make the verification with a single call. It also makes you write your test more explicitly. [TestMethod] public void AddingNewRequestSetsStatusToSubmitted() { //Arrange var mock = new Mock<IDRepository>(MockBehav...

Are Property Values In CSS Case-sensitive?

Answer : (updating @ÁlvaroG.Vicario answer and comments, and complementing this answer... This is a Wiki, please edit to enhance ) Example: for CSS3 (and HTML5) there are new explicit rules, as " font-face property must be case-insensitive".[2] Context W3C interoperating standards, mainly XML, HTML, CSV and CSS. CSS general rules CSS2 (a W3C standard of 2008) fixed basic conventions about "Characters and case", and CSS3 (a W3C standard for 2015) added something more. By default "all CSS syntax is case-insensitive (...)" [1] There are exceptions , "(...) except for parts that are not under the control of CSS"[1] 2.1. element names are case-sensitive in HTML5 (?) and XML, but case-insensitive in HTML4. 2.2. identifiers (including element names, classes, and IDs in selectors) are case-sensitive. HTML attributes id and class , of font names, and of URIs lies outside the scope of the CSS specification. .... The Case ...