public async Task POST_Inserts_Different_Region_Records() { var controller = new StationsController(Context); ConfigureRequest(controller); var newRegionId = Guid.NewGuid(); var model = new StationModel { Name = "Test No Id", RegionId = newRegionId }; Context.Regions.Add(new Region { Id = newRegionId, Name = "My New Region" }); Context.Stations.Add(new Station { Id = Guid.NewGuid(), Name = model.Name, RegionId = DefaultRegionId }); Context.SaveChanges(); var result = await GetResponse(controller.Post(model)); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }
public async Task POST_Is_OK() { var controller = new StationsController(Context); ConfigureRequest(controller); var model = new StationModel { Name = "Test No Id", RegionId = DefaultRegionId }; var result = await GetResponse(controller.Post(model)); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }
public async Task POST_Inserts_Records() { var controller = new StationsController(Context); ConfigureRequest(controller); var initialCount = Context.Stations.Count(); var model = new StationModel { Name = "Test No Id", RegionId = DefaultRegionId }; var result = await GetData <StationModel>(controller.Post(model)); Assert.IsNotNull(result); Assert.AreEqual(model.Name, result.Name); Assert.AreNotEqual(Guid.Empty, result.Id); }
public async Task Stations_Add() { // Arrange var controller = new StationsController(new StationService()); var nowObject = new Station { CallSign = "2DayFM", Code = "2DayFM", City = "Sydney", State = "NSW" }; // Act var result = await controller.Post(nowObject); // Assert var okResult = result.Should().BeOfType <CreatedAtActionResult>().Subject; var station = okResult.Value.Should().BeAssignableTo <Station>().Subject; station.Id.Should().Be(51); }