public void AddCoach_DeleteCoach_GetCoachList_IsNotFiguringOnList(string firstName, string surname, string email, string phoneNumber) { var trackingLogsService = new Mock <ITrackingLogsService>(); trackingLogsService.Setup(service => service.SendEvent( It.IsAny <TrackingLogEvent>())).Returns(ServiceResponse.Success()); var sut = new CoachService(new FakeCoachRepository(), trackingLogsService.Object); sut.EnsureInitialized("DummyURL", "0001"); var coach = new Coach() { FirstName = firstName, Surname = surname, Email = email, PhoneNumber = phoneNumber }; var addedCoach = sut.AddCoach(coach).ResponseDTO; sut.DeleteCoach(addedCoach.Id); var getCoachList = sut.GetCoachList().ResponseDTO; //getCoachList.Should().Match<List<Coach>>(response => response.Count==0); getCoachList.Should().NotContain(addedCoach); }
public void DeleteCoach_GetLatestLogs_IsEventSaved() { //mocking repos var fakeCoachRep = new FakeCoachRepository(); var newCoach = fakeCoachRep.InsertCoach(new Coach()); var fakeLogRep = new FakeTrackingLogEventRepository(); //systems under test ( tracking side) var trackingService = new TrackingService(fakeLogRep); var trackingController = new TrackingController(trackingService); _fixture.InitTrackingController(trackingController); //system under test ( main app side) var trackingLogsService = new TrackingLogsService(_fixture.Configuration, _fixture.FakeHttpService); var coachService = new CoachService(fakeCoachRep, trackingLogsService); //testing and assertions var deleteCoachResponse = coachService.DeleteCoach(newCoach.Id); deleteCoachResponse.Should().Match <ServiceResponse>(response => response.IsSuccess); var logListResponse = trackingLogsService.GetLatestLogs(); logListResponse.Should().Match <ServiceResponse <List <TrackingLogEvent> > >(response => response.IsSuccess); logListResponse.ResponseDTO.Should() .Contain(eventLog => eventLog.EventTypeId == TrackingLogEventType.CoachDeleted); }
public void AddCoach_DeleteCoach_GetCoach_IsNotFound(string firstName, string surname, string email, string phoneNumber) { var trackingLogsService = new Mock <ITrackingLogsService>(); trackingLogsService.Setup(service => service.SendEvent( It.IsAny <TrackingLogEvent>())).Returns(ServiceResponse.Success()); var sut = new CoachService(new FakeCoachRepository(), trackingLogsService.Object); sut.EnsureInitialized("DummyURL", "0001"); var coach = new Coach() { FirstName = firstName, Surname = surname, Email = email, PhoneNumber = phoneNumber }; var addedCoach = sut.AddCoach(coach).ResponseDTO; sut.DeleteCoach(addedCoach.Id); var getCoach = sut.GetCoach(addedCoach.Id); getCoach.Should().Match <ServiceResponse>(response => !response.IsSuccess && response.ErrorDetails.Code == 404); }
public void DeleteCoach_IsSuccess() { var coachRepositoryMock = new Mock <ICoachRepository>(); var coach = new Coach(); coachRepositoryMock.Setup(repository => repository.GetCoachById(coach.Id)).Returns(coach); coachRepositoryMock.Setup(repository => repository.DeleteCoach(coach)); var trackingLogsService = new Mock <ITrackingLogsService>(); trackingLogsService.Setup(service => service.SendEvent( It.IsAny <TrackingLogEvent>())).Returns(ServiceResponse.Success()); var sut = new CoachService(coachRepositoryMock.Object, trackingLogsService.Object); sut.EnsureInitialized("DummyURL", "0001"); sut.DeleteCoach(coach.Id).Should().Match <ServiceResponse>(response => response.IsSuccess); }