Ejemplo n.º 1
0
        public async Task GetByUserIdAsync_ShouldReturn_CorectDonor()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var seeder  = new Seeder();
            await seeder.SeedDonorAsync(context);

            var userManager  = this.GetUserManagerMock(context);
            var donorService = new DonorService(context, userManager.Object);

            var actualResult = await donorService.GetByUserIdAsync("userId1");

            Assert.True(actualResult.UserId == "userId1");
        }
Ejemplo n.º 2
0
        public async Task GetByUserIdAsync_ShouldThrownException_WithInvalidUser()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var seeder  = new Seeder();
            await seeder.SeedDonorAsync(context);

            var userManager  = this.GetUserManagerMock(context);
            var donorService = new DonorService(context, userManager.Object);

            await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await donorService.GetByUserIdAsync("invalidId");
            });
        }