Exemple #1
0
        public void GetAllWithSpecialitiesAsync_ShouldReturnRightNumberOfSpecialities()
        {
            //arrange
            var expected = GetUniversitiesWithSpecielitiesDTO().ToList();

            _uowMock.Setup(e => e.UniversityRepository.GetAllAsync().Result).Returns(GetUniversitiesWithSpecielitiesDAO());

            //act
            _sut = new UniversityService(_uowMock.Object, UTestHelper.CreateMapper());
            var actual = _sut.GetAllAsync().Result.ToList();

            //assert
            foreach (var expectedItem in expected)
            {
                Assert.AreEqual(expectedItem.Specialities.Count, actual.Single(e => e.Id == expectedItem.Id).Specialities.Count);
            }
        }
Exemple #2
0
        public void GetAllAsync_ShouldReturnAllSpecialities()
        {
            //arrange
            var expected = GetSpecialitiesDTO().ToList();

            _uowMock.Setup(e => e.SpecialityRepository.GetAllAsync().Result).Returns(GetSpecialitiesDAO());

            //act
            _sut = new SpecialityService(_uowMock.Object, UTestHelper.CreateMapper());
            var actual = _sut.GetAllAsync().Result.ToList();

            //assert
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i].Id, actual[i].Id);
                Assert.AreEqual(expected[i].Name, actual[i].Name);
            }
        }
Exemple #3
0
        public async Task CreateAsync_ShouldExecuteCreateMethod_WhenInboundDtoHasCollectionAtributes()
        {
            //arrange
            var applicationDTO = new UserApplicationModel
            {
                FirstName   = "Андрій",
                SecondName  = "Слижук",
                AverageMark = 200,
                PhoneNumber = 0661234567,
                Regions     = new List <RegionModel> {
                    new RegionModel {
                        Name = "Схід"
                    }, new RegionModel {
                        Name = "Захід"
                    }
                },
                ProfessionalDirections = new List <ProfessionalDirectionModel>
                {
                    new ProfessionalDirectionModel {
                        Name = "Програмування"
                    },
                    new ProfessionalDirectionModel {
                        Name = "Медицина"
                    },
                    new ProfessionalDirectionModel {
                        Name = "Фінанси"
                    }
                }
            };

            _uowMock.Setup(e => e.RegionRepository.GetByAsync(It.IsAny <Expression <Func <Region, bool> > >()).Result);
            _uowMock.Setup(e => e.ProfessionalDirectionRepository.GetByAsync(It.IsAny <Expression <Func <ProfessionalDirection, bool> > >()).Result);
            _uowMock.Setup(e => e.UserApplicationRepository.CreateAsync(It.IsAny <UserApplication>()));

            //Act
            _sut = new UserApplicationService(_uowMock.Object, UTestHelper.CreateMapper());
            await _sut.CreateAsync(applicationDTO);

            //Assert
            _uowMock.Verify(m => m.UserApplicationRepository.CreateAsync(It.IsAny <UserApplication>()), Times.Once);
        }