Exemplo n.º 1
0
        public void UpdateCoach_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 updateCoachResponse = coachService.UpdateCoach(newCoach);

            updateCoachResponse.Should().Match <ServiceResponse <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.CoachUpdated);
        }
Exemplo n.º 2
0
        public void AddCoach_IsNewIdReceived()
        {
            var coachRepositoryMock = new FakeCoachRepository();

            var trackingLogsService = new Mock <ITrackingLogsService>();

            trackingLogsService.Setup(service => service.SendEvent(
                                          It.IsAny <TrackingLogEvent>())).Returns(ServiceResponse.Success());

            var sut = new CoachService(coachRepositoryMock, trackingLogsService.Object);

            sut.EnsureInitialized("DummyURL", "0001");

            var coachResponse  = sut.AddCoach(new Coach());
            var coach2Response = sut.AddCoach(new Coach());

            coach2Response.Should().Match <ServiceResponse <Coach> >(response =>
                                                                     response.ResponseDTO.Id != 0 && coachResponse.ResponseDTO.Id != 0 &&
                                                                     response.ResponseDTO.Id != coachResponse.ResponseDTO.Id);
        }