public void AddCoach_GetCoachList_IsFiguringOnList(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; var obtainedCoachList = sut.GetCoachList().ResponseDTO; var obtainedCoach = obtainedCoachList.FirstOrDefault(c => c.Id == addedCoach.Id); obtainedCoach.Should().NotBeNull().And.Match <Coach>(c => c.FirstName == firstName && c.Surname == surname && c.Email == email && c.PhoneNumber == phoneNumber); }
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 GetCoachList_GetLatestLogs_IsEventSaved() { //mocking repos var fakeCoachRep = new FakeCoachRepository(); 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 coachListResponse = coachService.GetCoachList(); coachListResponse.Should().Match <ServiceResponse <List <Coach> > >(response => response.IsSuccess); var logListResponse = trackingLogsService.GetLatestLogs(); logListResponse.Should().Match <ServiceResponse <List <TrackingLogEvent> > >(response => response.IsSuccess); logListResponse.ResponseDTO.Should() .Contain(eventLog => eventLog.EventTypeId == TrackingLogEventType.CoachListVisited); }
public void GetCoachList_IsSuccess() { var coachRepositoryMock = new Mock <ICoachRepository>(); coachRepositoryMock.Setup(repository => repository.GetCoaches()).Returns(new List <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.GetCoachList().Should().Match(response => response.As <ServiceResponse>().IsSuccess); }
protected void CoachList() { ICoachInterface coachInterface = new CoachService(); var lst = coachInterface.GetCoachList().Select(x => new { x.CoachName, x.ID }).ToList(); DataTable dt = ToDataTable(lst); if (dt != null && dt.Rows.Count > 0) { CoachID.DataSource = dt; CoachID.DataTextField = "CoachName"; CoachID.DataValueField = "ID"; CoachID.DataBind(); } else { CoachID.DataBind(); } }
public void GetCoachList_IsCorrectCoachCount(int coachCount) { var coachList = new List <Coach>(); for (int i = 0; i < coachCount; i++) { coachList.Add(new Coach()); } var coachRepositoryMock = new Mock <ICoachRepository>(); coachRepositoryMock.Setup(repository => repository.GetCoaches()).Returns(coachList); 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.GetCoachList().Should().BeOfType <ServiceResponse <List <Coach> > >() .And.Match(response => response.As <ServiceResponse <List <Coach> > >().ResponseDTO.Count == coachCount); }