public void BuildResultsByGameTest() { Database.SetInitializer <SelectumContext>(null); int currentGameFilterId = 1; int userId = 1; string viewBagMessageToUser = string.Empty; // expected string expectedMessageToUser = "******"; var expected = new ResultsByGame(); expected.Results = new List <ResultByGame>(); expected.Totals = new List <int>(); expected.Users = new List <User>(); expected.Results.Add(new ResultByGame()); ResultsByGameController controller = new ResultsByGameController(); ResultsByGame actual = controller.BuildResultsByGame(currentGameFilterId, userId, ref viewBagMessageToUser); actual.Results = new List <ResultByGame>(); actual.Results.Add(new ResultByGame()); actual.Users = new List <User>(); Assert.AreEqual(expectedMessageToUser, viewBagMessageToUser); UnitTestingHelper.AssertPublicPropertiesEqual(expected, actual); }
public void GameFilter() { //AreaRegistration.RegisterAllAreas(); //WebApiConfig.Register(GlobalConfiguration.Configuration); //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); //RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); //AuthConfig.RegisterAuth(); //Database.SetInitializer<SelectumContext>(new SelectumInitializer()); Database.SetInitializer <SelectumContext>(null); int id = 0; // expecteds string messageToUser = "******"; var resultsViewModel = new ResultsByGame(); resultsViewModel.Results.Add(new ResultByGame()); ResultsByGameController controller = new ResultsByGameController(); ViewResult result = controller.GameFilter(id) as ViewResult; Assert.AreEqual(messageToUser, result.ViewBag.MessageToUser); IgnoreProperties ignoreProps = new IgnoreProperties(); ignoreProps.Add(new PropertyComparisonExclusion(typeof(List <string>), "Capacity")); UnitTestingHelper.AssertPublicPropertiesEqual(resultsViewModel, result.Model, ignoreProps); }
public void Can_correctly_map_data_row_to_class_with_public_getters() { var dataColumns = new[] { "username", "password", "dni_cuit", "fallas" } .Select(name => new DataColumn(name)) .ToArray(); var dataTable = new DataTable(); dataTable.Columns.AddRange(dataColumns); var row = dataTable.NewRow(); row["username"] = "******"; row["password"] = "******"; row["dni_cuit"] = "36528600"; row["fallas"] = 2; var adapter = new Adapter(); var adaptedUser = adapter.Transform <Usuario>(row); var expectedUser = new Usuario { username = "******", password = "******", dni_cuit = "36528600", fallas = 2 }; UnitTestingHelper.AssertPublicPropertiesEqual(expectedUser, adaptedUser); }