Exemple #1
0
        public async Task ShouldMigrateFromScratch()
        {
            var migrator = new ProfileMigrations(_localStorageServiceMock.Object);

            var container = await migrator.StartMigration(null);

            container.Should().NotBeNull();
            container.Version.Should().Be(2);
            container.Profiles.Should().BeEmpty().And.NotBeNull();
        }
Exemple #2
0
        public async Task ShouldMigrateFromExistingConfigPartial()
        {
            var faceApiConfig = new Dictionary <string, CognitiveServiceConfig>
            {
                { "MyCompany", new CognitiveServiceConfig("FaceApi", "http://mycompany-cservice.com", "token1") },
                { "Contoso", new CognitiveServiceConfig("FaceApi", "http://contoso-cservice.com", "token2") }
            };

            _localStorageServiceMock
            .Setup(x => x.GetItemAsync <Dictionary <string, CognitiveServiceConfig> >("cs-config-profile-FaceApi"))
            .ReturnsAsync(faceApiConfig)
            .Verifiable();

            _localStorageServiceMock
            .Setup(x => x.SetItemAsync("Profiles", It.IsAny <object>()))
            .Verifiable();

            var migrator = new ProfileMigrations(_localStorageServiceMock.Object);

            var container = await migrator.StartMigration(null);

            container.Should().NotBeNull();
            container.Version.Should().Be(2);
            container.Profiles.Should()
            .SatisfyRespectively(
                first =>
            {
                first.Id.Should().NotBe(Guid.Empty);
                first.ProfileName.Should().Be("MyCompany");
                first.IsSelected.Should().BeTrue();
                first.FaceApiConfig.Should().NotBeNull();
                first.FaceApiConfig !.ServiceName.Should().Be("FaceApi");
                first.FaceApiConfig.BaseUrl.Should().Be("http://mycompany-cservice.com");
                first.FaceApiConfig.Token.Should().Be("token1");
            },
                second =>
            {
                second.Id.Should().NotBe(Guid.Empty);
                second.ProfileName.Should().Be("Contoso");
                second.IsSelected.Should().BeFalse();
                second.FaceApiConfig.Should().NotBeNull();
                second.FaceApiConfig !.ServiceName.Should().Be("FaceApi");
                second.FaceApiConfig.BaseUrl.Should().Be("http://contoso-cservice.com");
                second.FaceApiConfig.Token.Should().Be("token2");
            });

            _localStorageServiceMock.Invocations.Should().HaveCount(13);
            _localStorageServiceMock.Verify();
        }
Exemple #3
0
        public async Task ShouldNotMigrateIfAlreadyMigrated()
        {
            var migrator = new ProfileMigrations(_localStorageServiceMock.Object);

            var container = await migrator.StartMigration(new ProfileStorageContainer
            {
                Version = 2
            });

            container.Should().NotBeNull();
            container.Version.Should().Be(2);
            container.Profiles.Should().BeEmpty();

            // Should not use local storage.
            _localStorageServiceMock.Invocations.Should().BeEmpty();
        }