Exemplo n.º 1
0
        public async Task Should_restore_users()
        {
            var user1 = CreateUser("user1", "*****@*****.**");
            var user2 = CreateUser("user2", "*****@*****.**");

            var reader = SetupReader(user1, user2);

            var userResolver = A.Fake <IUserResolver>();

            A.CallTo(() => userResolver.FindByIdOrEmailAsync(user1.Email))
            .Returns(user1);

            A.CallTo(() => userResolver.FindByIdOrEmailAsync(user2.Email))
            .Returns(user2);

            await sut.RestoreAsync(reader, userResolver);

            Assert.True(sut.TryMap("user1_old", out var mapped1));
            Assert.Equal(Subject("user1"), mapped1);

            Assert.True(sut.TryMap(Subject("user2_old"), out var mapped2));
            Assert.Equal(Subject("user2"), mapped2);
        }
Exemplo n.º 2
0
        public async Task Should_restore_users()
        {
            var user1 = UserMocks.User("1", "*****@*****.**");
            var user2 = UserMocks.User("2", "*****@*****.**");

            var reader = SetupReader(user1, user2);

            var userResolver = A.Fake <IUserResolver>();

            A.CallTo(() => userResolver.CreateUserIfNotExistsAsync(user1.Email, false, ct))
            .Returns((user1, false));

            A.CallTo(() => userResolver.CreateUserIfNotExistsAsync(user2.Email, false, ct))
            .Returns((user2, true));

            await sut.RestoreAsync(reader, userResolver, ct);

            Assert.True(sut.TryMap("1_old", out var mapped1));
            Assert.True(sut.TryMap(Subject("2_old"), out var mapped2));

            Assert.Equal(Subject("1"), mapped1);
            Assert.Equal(Subject("2"), mapped2);
        }