コード例 #1
0
        public async Task ThrowNotFoundException_WhenLectorIsNotExists()
        {
            var request = new UpdateLectorCommand
            {
                Id = 100,
                AcademicDegreeId = 1,
                AcademicRankId   = 1,
                Email            = "*****@*****.**",
                FirstName        = "Name 1",
                LastName         = "LastName 1",
                Patronymic       = "Patronymic 1",
                PhoneNumber      = "+0000000000"
            };

            var handler   = new UpdateLectorCommandHandler(Context);
            var exception = Assert.ThrowsAsync <NotFoundException>(async() => await handler.Handle(request, CancellationToken.None));

            Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetNotFoundExceptionMessage(nameof(Lector), request.Id));
        }
コード例 #2
0
        public async Task UpdateLector_And_User()
        {
            var request = new UpdateLectorCommand
            {
                Id = 1,
                AcademicDegreeId = 1,
                AcademicRankId   = 1,
                Email            = "*****@*****.**",
                FirstName        = "Name 1",
                LastName         = "LastName 1",
                Patronymic       = "Patronymic 1",
                PhoneNumber      = "+0000000000"
            };

            var handler = new UpdateLectorCommandHandler(Context);

            var result = await handler.Handle(request, CancellationToken.None);

            Assert.IsTrue(Context.Lectors.Where(x => x.Id == request.Id && x.Email == request.Email).Count() == 1);
            Assert.IsTrue(Context.Users.Where(x => x.Id == 100 && x.Email == request.Email).Count() == 1);
        }