public virtual async void TestDelete() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IDeviceService service = testServer.Host.Services.GetService(typeof(IDeviceService)) as IDeviceService; var model = new ApiDeviceServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), true, "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); CreateResponse <ApiDeviceServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.DeviceDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiDeviceServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void MapServerRequestToResponse() { var mapper = new ApiDeviceServerModelMapper(); var model = new ApiDeviceServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), true, "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); ApiDeviceServerResponseModel response = mapper.MapServerRequestToResponse(1, model); response.Should().NotBeNull(); response.DateOfLastPing.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.IsActive.Should().Be(true); response.Name.Should().Be("A"); response.PublicId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); }
public void CreatePatch() { var mapper = new ApiDeviceServerModelMapper(); var model = new ApiDeviceServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), true, "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); JsonPatchDocument <ApiDeviceServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiDeviceServerRequestModel(); patch.ApplyTo(response); response.DateOfLastPing.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.IsActive.Should().Be(true); response.Name.Should().Be("A"); response.PublicId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); }