예제 #1
0
        public async Task Then_The_Total_Is_Returned(
            int ukprn,
            int?courseId,
            double?lat,
            double?lon,
            int?radius,
            CourseDemand courseDemand1,
            CourseDemand courseDemand2,
            CourseDemand courseDemand3,
            [Frozen] Mock <IEmployerDemandDataContext> mockDbContext,
            Data.Repository.CourseDemandRepository repository)
        {
            //arrange
            courseDemand1.CourseId = courseDemand2.CourseId;
            mockDbContext
            .Setup(context => context.CourseDemands)
            .ReturnsDbSet(new List <CourseDemand> {
                courseDemand1, courseDemand2, courseDemand3
            });

            //Act
            var result = await repository.TotalCourseDemands(ukprn);

            //Assert
            result.Should().Be(2);
        }
예제 #2
0
        public void Arrange()
        {
            _courseDemandItem =
                new CourseDemand()
            {
                Id          = Guid.NewGuid(),
                DateCreated = DateTime.Now
            };

            _employerDemandDataContext = new Mock <IEmployerDemandDataContext>();
            _employerDemandDataContext.Setup(x => x.CourseDemands).ReturnsDbSet(new List <CourseDemand>());
            _courseDemandRepository = new Data.Repository.CourseDemandRepository(Mock.Of <ILogger <Data.Repository.CourseDemandRepository> >(), _employerDemandDataContext.Object);
        }
        public async Task <bool> Insert(CourseDemand item)
        {
            try
            {
                await _dataContext.CourseDemands.AddAsync(item);

                _dataContext.SaveChanges();
                return(true);
            }
            catch (DbUpdateException e)
            {
                _logger.LogInformation(e, "Unable to add course demand item");
            }
            return(false);
        }
        public void Then_The_Fields_Are_Correctly_Mapped(CourseDemand source)
        {
            //Act
            var actual = (Domain.Entities.CourseDemand)source;

            //Assert
            actual.Should().BeEquivalentTo(source, options => options
                                           .Excluding(c => c.Location)
                                           .Excluding(c => c.Course)
                                           );
            actual.CourseId.Should().Be(source.Course.Id);
            actual.CourseTitle.Should().Be(source.Course.Title);
            actual.CourseLevel.Should().Be(source.Course.Level);
            actual.CourseRoute.Should().Be(source.Course.Route);
            actual.LocationName.Should().Be(source.Location.Name);
            actual.Lat.Should().Be(source.Location.Lat);
            actual.Long.Should().Be(source.Location.Lon);
        }