public void Customize(IFixture fixture) { IConfiguration configRoot = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary <string, string> { { "BugClientUrl", "http://localhost:80/bugsapi/" }, { "Loggers:0", "1" }, { "Loggers:1", "2" }, { "Loggers:2", "3" } }) .Build(); var autoMockCuztomisation = fixture.Customize(new AutoMoqCustomization()); var bug = fixture.Build <BugModel>().CreateMany(); var listOfBugs = fixture.Build <List <BugModel> >().Create(); var messageHandler = new Mock <HttpMessageHandler>(); var httpClient = new HttpClient(messageHandler.Object); var bugApiRequest = new BugsApiRequest(configRoot, httpClient); fixture.Register(() => autoMockCuztomisation); fixture.Register(() => bug); fixture.Register(() => configRoot); fixture.Register(() => listOfBugs); fixture.Register(() => httpClient); fixture.Register(() => bugApiRequest); }
public void DeleteBugsAsync_should_be_faulted_if_Incorrect_response_from_api(IFixture fixture, BugsApiRequest sut) { //Arrange var request = new Mock <IBugsApiRequest>(); request.Setup(x => x.DeleteBugAsync(1)).Returns(DeleteBugAsync(1)); //Act var actual = sut.CreateBugAsync(fixture.Create <string>()); //Assert actual.Status.Should().Be(TaskStatus.Faulted); }
public void CreateBugAsync_Should_not_beCompleted_Succesfully_since_app_is_not_upp_on_docker_network([Frozen] BugsApiRequest sut, IFixture fixture) { //Act var actual = sut.CreateBugAsync(fixture.Create <string>()); //Assert actual.IsCompletedSuccessfully.Should().BeFalse(); }
public void CreateBugsAsync_should_not_throw_exception_if_correct_response_from_api(IFixture fixture, BugsApiRequest sut, BugModel bugModel) { //Arrange var request = new Mock <IBugsApiRequest>(); request.Setup(x => x.CreateBugAsync(fixture.Create <string>())).Returns(CreateBugAsync(fixture.Create <string>())); //Act Action actual = () => sut.CreateBugAsync(fixture.Create <string>()); //Assert actual.Should().NotThrow(); }
public void DeleteBugAsync_Should_not_beCompleted_Succesfully_since_app_is_not_upp_on_docker_network([Frozen] BugsApiRequest sut) { //Act var actual = sut.DeleteBugAsync(1); //Assert actual.IsCompletedSuccessfully.Should().BeFalse(); }