public async Task UpdateAgentAsyncShouldChangeName(string expectedName) { var service = new AgentService(Context); var itemToUpdate = await service.GetAgentAsync(FirstItem.Id); itemToUpdate.Name = expectedName; await service.UpdateAgentAsync(FirstItem); var updatedItem = await service.GetAgentAsync(FirstItem.Id); Assert.AreEqual(expectedName, updatedItem.Name); }
public async Task GetAsyncShouldReturnCorrectAgent() { var service = new AgentService(Context); var actualItem = await service.GetAgentAsync(FirstItem.Id); Assert.AreEqual(FirstItem.Id, actualItem.Id); }
public async Task UpdateAgentAsyncWithPropertyNameIsNullShouldThrowException() { var service = new AgentService(Context); var itemToUpdate = await service.GetAgentAsync(FirstItem.Id); itemToUpdate.Name = null; Assert.ThrowsAsync <DbUpdateException>(() => service.UpdateAgentAsync(itemToUpdate)); }
public void ShouldReturnAnAgent() { var agentJson = StubDataLoader.LoadJsonFile("Agent.json"); IAgentService service = new AgentService(new MoxiWorksClient(new StubContextClient(agentJson))); var response = service.GetAgentAsync("some_agent_id", "some_company_id").Result; Assert.IsType <Agent>(response.Item); Assert.True(response.Item.CreatedTimestamp.HasValue); Assert.False(response.Item.DeactivatedTimestamp.HasValue); }
public void ShouldReturnAgentWithAlternateOffices() { var agentJson = StubDataLoader.LoadJsonFile("Agent.json"); IAgentService service = new AgentService(new MoxiWorksClient(new StubContextClient(agentJson))); var response = service.GetAgentAsync("some_agent_id", "some_company_id").Result; var agent = response.Item; Assert.True(agent.AlternateOffices.Count == 2); Assert.Equal(1234, agent.AlternateOffices[0].OfficeId); }