Exemplo n.º 1
0
        public void Given_Create_When_DataIsProvided_Then_ShouldReturnEntity()
        {
            // act
            var result = Course.Create("test", CourseHolder.Create("*****@*****.**"));

            // assert
            Assert.NotNull(result);
        }
Exemplo n.º 2
0
        public void Given_Handle_When_AfterContentIsCreated_Then_ShouldRaiseDomainEvent()
        {
            courseHolderRepositoryMock.Setup(x => x.GetByEmail(holderEmail)).Returns(CourseHolder.Create(holderEmail));

            // act
            var result = Handler().Handle(Command(), CancellationToken.None).Result;

            // assert
            eventsDispatcher.Verify(x => x.Raise(It.IsAny <CourseCreatedEvent>()));
        }
Exemplo n.º 3
0
        public void Given_Delete_Then_ShouldSetIsDeletedToTrue()
        {
            // arrange
            var course = Course.Create("test", CourseHolder.Create("*****@*****.**"));

            // act
            course.Delete();

            // assert
            Assert.True(course.IsDeleted);
        }
Exemplo n.º 4
0
        public void Given_Handle_When_AfterContentIsCreated_Then_ShouldSaveToDatabase()
        {
            courseHolderRepositoryMock.Setup(x => x.GetByEmail(holderEmail)).Returns(CourseHolder.Create(holderEmail));

            // act
            var result = Handler().Handle(Command(), CancellationToken.None).Result;

            // assert
            courseReposiotryMock.Verify(x => x.Add(It.IsAny <Domain.Course>()));
            courseReposiotryMock.Verify(x => x.SaveChanges());
        }
Exemplo n.º 5
0
        public void Given_Handle_When_CourseHolderIsFound_Then_ShouldReturnOkResult()
        {
            // arrange
            courseHolderRepositoryMock.Setup(x => x.GetByEmail(holderEmail)).Returns(CourseHolder.Create(holderEmail));

            // act
            var result = Handler().Handle(Command(), CancellationToken.None).Result;

            // assert
            Assert.True(result.IsSuccess);
        }
        public Task Handle(UserRegisteredEvent @event)
        {
            EnsureArg.IsNotNull(@event);

            if (@event.Role == TeacherRole)
            {
                var holder = CourseHolder.Create(@event.Email);
                courseHolderRespository.Add(holder);
                courseHolderRespository.SaveChanges();
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 7
0
        public void Given_Handle_When_QueryIsNotNull_Then_ShouldRetrunModels()
        {
            // arrange
            coursesRepositoryMock.Setup(x => x.GetAll())
            .Returns(
                new List <Domain.Course> {
                Domain.Course.Create("test", CourseHolder.Create("test"))
            }.AsQueryable());
            mapperMock.Setup(x => x.Map <IEnumerable <CourseModel> >(It.IsAny <IEnumerable <Domain.Course> >()))
            .Returns(new List <CourseModel> {
                new CourseModel()
            });

            // act
            var result = Handler().Handle(Query(), CancellationToken.None).Result;

            // assert
            Assert.True(result.Any());
        }