示例#1
0
        public async Task Test_GetAll_Should_Return_Only_Contragents_For_Current_User()
        {
            using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions());
            var contragentsService = new ContragentsService(inMemoryDb);
            var usersService       = new UsersService(inMemoryDb);

            var createdUsedId = await usersService.CreateAsync("TestUsername", "123");

            await contragentsService.CreateAsync("Test", "Testovo", "*****@*****.**", "123456", createdUsedId);

            await contragentsService.CreateAsync("Test1", "Testovo1", "*****@*****.**", "1234567", createdUsedId);

            await contragentsService.CreateAsync("Test2", "Testovo2", "*****@*****.**", "12345678", "otherId");

            var allContragents = contragentsService.GetAll(createdUsedId);

            Assert.Equal(2, allContragents.Count());
            Assert.Equal(3, inMemoryDb.Contragents.Count());
        }
示例#2
0
        public async Task Test_Create_Should_Create()
        {
            using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions());
            var contragentsService = new ContragentsService(inMemoryDb);
            var usersService       = new UsersService(inMemoryDb);

            var createdUsedId = await usersService.CreateAsync("TestUsername", "123");

            await contragentsService.CreateAsync("Test", "Testovo", "*****@*****.**", "123456", createdUsedId);

            Assert.Equal(1, inMemoryDb.Contragents.Count());
        }