Ejemplo n.º 1
0
        public async Task Handle_DefaultMarkupPlansObjectUpdated_UpdatesAreReflectedInDb()
        {
            // Arrange
            var markupPlan = await CreateMarkupPlanUsingAutoFixture(1);

            // update properties
            var defaultMarkupPlans = markupPlan.DefaultMarkupPlans.First();

            defaultMarkupPlans.MarkupPlanId = _fixture.Create <int>();
            defaultMarkupPlans.Module       = _fixture.Create <ModuleTypes>();

            // AutoMapper setup
            _mapperMock.Setup(m => m.Map(It.IsAny <UpdateMarkupPlanCommand>(), It.IsAny <MarkupPlan>())).Returns(markupPlan);

            // creating System Under Test
            var sut = new UpdateMarkupPlanCommandHandler(_context, _mapperMock.Object);

            // Act
            await sut.Handle(new UpdateMarkupPlanCommand(), CancellationToken.None);

            // Assert
            var dbDefaultMarkupPlans = _context.DefaultMarkupPlans.First();

            dbDefaultMarkupPlans.MarkupPlanId.ShouldBe(defaultMarkupPlans.MarkupPlanId);
            dbDefaultMarkupPlans.Module.ShouldBe(defaultMarkupPlans.Module);
        }
Ejemplo n.º 2
0
        public async Task Handle_MarkupPlanObjectSimplePropertiesUpdated_UpdatesAreReflectedInDb()
        {
            // Arrange
            var markupPlan = await CreateMarkupPlanUsingAutoFixture(0);

            // update properties
            markupPlan.CanUseCoupon = _fixture.Create <bool>();
            markupPlan.Name         = _fixture.Create <string>();

            // AutoMapper setup
            _mapperMock.Setup(m => m.Map(It.IsAny <UpdateMarkupPlanCommand>(), It.IsAny <MarkupPlan>())).Returns(markupPlan);

            // creating System Under Test
            var sut = new UpdateMarkupPlanCommandHandler(_context, _mapperMock.Object);

            // Act
            await sut.Handle(new UpdateMarkupPlanCommand(), CancellationToken.None);

            // Assert
            var dbMarkupPlan = _context.MarkupPlans.First();

            dbMarkupPlan.CanUseCoupon.ShouldBe(markupPlan.CanUseCoupon);
            dbMarkupPlan.Name.ShouldBe(markupPlan.Name);
        }