Thus, the Agile standard philosophy would recommend making your domain classes simple POCOs that are stored using a separate proxy level through data access objects (e.g. NHibernate). He also recommends getting the maximum unit test coverage possible.
Does it make sense to write tests for these simple POCO objects? Let's say I have a class that looks like this:
public class Container { public int ContainerId { get; set;} public string Name { get; set;} public IList<Item> Contents { get; set;} }
What useful unit tests can I write for this?
Typically, such a value object should not have its own tests. You will get coverage from classes that use it to do something.
. ? .
, , , , . , , , , , , null . , , , , , . , , , .
, ContainerId ? ? , .. , , null , , ?
, . , , , Factory. Factory, , , .
, , , , .
, , , , - (.. ).
, . , Container() . , , .
unit test "" .
, , - ; , , .
, .
Contents. .
Contents
I would say that this is not even an object, but an object is determined by its behavior, and this class does not. This is a clean data container. This is also normal, and they usually do not need any tests, but be careful not to get the Anemic Domain Model . Using Test Driven Development will “make” you first think about the behavior of your classes and can be a good exercise.
Source: https://habr.com/ru/post/1699617/More articles:SQL Server Express / MS Access LINQ features, which one to use? - c #Can I use ODAC 11g to access 10g - oracleChange onfocus handler element with javascript? - javascriptSimpleXML or XMLReader? - xmlСтруктура анализа и тестирования XML-over-HTTP - httpWhat RAD tools exist for creating a GUI in Perl? - user-interfaceHall of Fame / Shame Emacs - emacsHow to use native custom mouse cursors from Flash applications? - flexWhy did Microsoft decide to host 32-bit applications in "Program Files (x86)"? - vista64vb6 Open file to add problem No path found - appendAll Articles