public async Task GET_Returns_Ordered_List() { var controller = new UnitOfMeasuresController(Context); base.ConfigureRequest(controller); Context.UnitsOfMeasure.Add(new UnitOfMeasure { Id = Guid.NewGuid(), Name = "My Custom UnitOfMeasure" }); Context.UnitsOfMeasure.Add(new UnitOfMeasure { Id = Guid.NewGuid(), Name = "A different name" }); Context.SaveChanges(); var orderedList = await GetData <List <UnitOfMeasureModel> >(controller.Get(true)); Assert.AreEqual(2, orderedList.Count()); Assert.AreNotEqual(Guid.Empty, orderedList.First().Id); Assert.AreNotEqual(Guid.Empty, orderedList.Last().Id); Assert.AreEqual("A different name", orderedList.First().Name); Assert.AreEqual("My Custom UnitOfMeasure", orderedList.Last().Name); }
public async Task GET_Returns_Ordered_By_Name_Then_Deleted() { var controller = new UnitOfMeasuresController(Context); base.ConfigureRequest(controller); Context.UnitsOfMeasure.Add(new UnitOfMeasure { Id = Guid.NewGuid(), Name = "My Custom UnitOfMeasure" }); Context.UnitsOfMeasure.Add(new UnitOfMeasure { Id = Guid.NewGuid(), Name = "A different name" }); Context.UnitsOfMeasure.Add(new UnitOfMeasure { Id = Guid.NewGuid(), Name = "A third name", IsMarkedAsDeleted = true }); Context.SaveChanges(); var orderedList = await GetData <List <UnitOfMeasureModel> >(controller.Get(true)); Assert.AreEqual(3, orderedList.Count()); Assert.AreEqual("A different name", orderedList.First().Name); Assert.AreEqual("My Custom UnitOfMeasure", orderedList.ElementAt(1).Name); Assert.AreEqual("A third name", orderedList.Last().Name); }
public async Task GET_Is_OK() { var controller = new UnitOfMeasuresController(Context); ConfigureRequest(controller); var result = await GetResponse(controller.Get(true)); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }
public async Task GET_Returns_List() { var controller = new UnitOfMeasuresController(Context); base.ConfigureRequest(controller); // Act var result = await GetData <List <UnitOfMeasureModel> >(controller.Get(true)); // Assert Assert.IsNotNull(result); Assert.AreEqual(0, result.Count); }