public void ControllerInvokesEventEmitterAndReturnsCreated() { CommandEventConverter converter = new CommandEventConverter(); FakeEventEmitter emitter = new FakeEventEmitter(); FakeTeamServiceClient teamServiceClient = new FakeTeamServiceClient(); LocationReportsController controller = new LocationReportsController(converter, emitter, teamServiceClient); LocationReport report = new LocationReport { Latitude = 10.0, Longitude = 10.0, Origin = "TESTS", MemberID = Guid.NewGuid(), ReportID = Guid.NewGuid() }; var result = controller.PostLocationReport(report.MemberID, report); Assert.True(emitter.MemberLocationRecordedEvents.Count == 1); Assert.Equal(emitter.MemberLocationRecordedEvents[0].Latitude, report.Latitude); Assert.Equal(emitter.MemberLocationRecordedEvents[0].Longitude, report.Longitude); Assert.Equal(emitter.MemberLocationRecordedEvents[0].Origin, report.Origin); Assert.Equal(emitter.MemberLocationRecordedEvents[0].MemberID, report.MemberID); Assert.Equal(emitter.MemberLocationRecordedEvents[0].ReportID, report.ReportID); Assert.Equal(emitter.MemberLocationRecordedEvents[0].TeamID, teamServiceClient.FixedID); Assert.Equal(201, (result as ObjectResult).StatusCode.Value); }
public void AugmentsCommandWithTimestamp() { long startTime = DateTime.Now.ToUniversalTime().Ticks; LocationReport command = new LocationReport { Latitude = 10.0, Longitude = 30.0, Origin = "TESTS", MemberID = Guid.NewGuid() }; CommandEventConverter converter = new CommandEventConverter(); MemberLocationRecordedEvent recordedEvent = converter.CommandToEvent(command); Assert.Equal(command.Latitude, recordedEvent.Latitude); Assert.Equal(command.Longitude, recordedEvent.Longitude); Assert.Equal(command.Origin, recordedEvent.Origin); Assert.True(recordedEvent.RecordedTime >= startTime); }