public void GetLastLocation() { // Arrange ILocationRecordRepository repository = new InMemoryLocationRecordRepository(); var controller = new LocationRecordController(repository); var newMemberId = Guid.NewGuid(); var newLocation = new LocationRecord() { ID = Guid.NewGuid(), Timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(), MemberID = Guid.NewGuid() }; var lastLocation = new LocationRecord() { ID = Guid.NewGuid(), Timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(), MemberID = Guid.NewGuid() }; repository.Add(newLocation); repository.Add(lastLocation); // Act var result = (LocationRecord)(controller.GetLatestForMember(newMemberId) as ObjectResult).Value; // Assert Assert.Equal(lastLocation.ID, result.ID); }
public void GetLocationForMemberReturns() { // Arrange ILocationRecordRepository repository = new InMemoryLocationRecordRepository(); var controller = new LocationRecordController(repository); var newMemberId = Guid.NewGuid(); var newLocation = new LocationRecord() { ID = Guid.NewGuid(), MemberID = Guid.NewGuid() }; var lastLocation = new LocationRecord() { ID = Guid.NewGuid(), MemberID = Guid.NewGuid() }; repository.Add(newLocation); repository.Add(lastLocation); // Act var result = (ICollection <LocationRecord>)(controller.GetLocationsForMember(newMemberId) as ObjectResult).Value; // Assert Assert.Equal(2, result.Count); Assert.True(result.Contains(lastLocation)); Assert.True(result.Contains(newLocation)); }