public async Task WhenInactiveProfileExist_ItIsSelected() { //Arrange var firstProfile = new Profile("testDevice1", "testPushToken1", "en-US", "TestAuthToken"); firstProfile.BeginQuarantine(TimeSpan.FromDays(1)); var profiles = new List <Profile> { firstProfile }; contextMock.Setup(x => x.Profiles).ReturnsDbSet(profiles); var repository = new CoronaRepository(contextMock.Object); //Act var inactiveProfiles = await repository .GetInactiveUsersInQuarantineAsync(DateTime.UtcNow.AddDays(-2), default(CancellationToken)); //Assert inactiveProfiles.Should().HaveCount(1); }
public async Task WhenMultipleProfilesWithSamePhoneNumberExist_AndNoOneSendLocation_OnlyOneProfileIsSelected() { //Arrange var firstProfile = new Profile(1, "testDevice1", "testPushToken1", "en-US", "TestAuthToken", "TestPhoneNumber"); firstProfile.BeginQuarantine(TimeSpan.FromDays(1)); var secondProfile = new Profile(2, "testDevice2", "testPushToken2", "en-US", "TestAuthToken", "TestPhoneNumber"); secondProfile.BeginQuarantine(TimeSpan.FromDays(1)); var profiles = new List <Profile> { firstProfile, secondProfile }; contextMock.Setup(x => x.Profiles).ReturnsDbSet(profiles); var repository = new CoronaRepository(contextMock.Object); //Act var inactiveProfiles = await repository .GetInactiveUsersInQuarantineAsync(DateTime.UtcNow.AddDays(-2), default(CancellationToken)); //Assert inactiveProfiles.Should().HaveCount(1); }
public RepositoryIntegrationTests() { var contextOption = new DbContextOptionsBuilder <CoronaContext>(); contextOption.UseCosmos( configurationSection["CosmosEndpoint"], configurationSection["CosmosAuthKey"], configurationSection["CosmosDatabase"]); var context = new CoronaContext(contextOption.Options); repository = new CoronaRepository(context); var client = new HttpClient { BaseAddress = new Uri(configurationSection["FirebaseUrl"]) }; client.DefaultRequestHeaders.Add("Authorization", $"key = {configurationSection["FirebaseServerKey"]}"); client.DefaultRequestHeaders.Add("Sender", $"id = {configurationSection["FirebaseSenderId"]}"); pushService = new FirebaseCloudMessagingService(client); }