This is an example function that works with an entity, stores it in db, and then causes problems because we cannot write Unit Test for it. Check this:
public class EmployeeSaver
{
....
public void Go()
{
Employee e = new Employee();
e.Name="Jeremiah";
...
_DataContext.Employees.Add(e);
_DataContext.SubmitChanges();
}
}
Because of the nature of RIA services, DomainService does not start inside the Silverlight Unit Testing platform. This means that I do not have access to the RIA when I perform my unit tests.
We were thinking about mock databases, but this class actually creates an Entity (Employee) to add to the database. This is problematic because Mock Databases do not use this object, but the MockEntity class, which is similar to the original object.
We are not trying to test the RIA itself, but how do we use entities created by the RIA.
My ultimate goal would be to write a function like this:
[TestMethod]
public void Test()
{
EmployeeSaver s = new EmployeeSaver();
s.Go();
Assert.IsEqual( DataContext.Employees.Last().Name, "Jeremiah" );
}
? ? Silverlight Testing Framework?