Пример #1
0
        public void Validate_Buyer_AllOperations_ReturnsError(
            [ValueSource(nameof(Operations))] string operation
            )
        {
            var ctx = Creator.GetContext(role: Roles.Buyer);

            _context.Setup(c => c.HttpContext).Returns(ctx);
            var validator = new AssessmentMessageValidator(_context.Object);

            var res = validator.Validate(Creator.GetAssessmentMessage(), ruleSet: operation);

            res.Errors.Count().Should().Be(1);
        }
Пример #2
0
        public void Validate_AdminSupplier_BySolutionCreate_ReturnsNoError(
            [Values(nameof(IAssessmentMessageLogic.BySolution), nameof(IAssessmentMessageLogic.Create))] string operation,
            [Values(Roles.Admin, Roles.Supplier)] string role
            )
        {
            var ctx = Creator.GetContext(role: role);

            _context.Setup(c => c.HttpContext).Returns(ctx);
            var validator = new AssessmentMessageValidator(_context.Object);

            var res = validator.Validate(Creator.GetAssessmentMessage(), ruleSet: operation);

            res.Errors.Should().BeEmpty();
        }
        public void Filter_Buyer_ReturnsEmpty()
        {
            var ctx = Creator.GetContext(role: Roles.Buyer);

            _context.Setup(c => c.HttpContext).Returns(ctx);
            var filter    = new AssessmentMessageFilter(_context.Object, _solutionDatastore.Object);
            var assMesses = new[]
            {
                Creator.GetAssessmentMessage(),
                Creator.GetAssessmentMessage(),
                Creator.GetAssessmentMessage()
            };

            var res = filter.Filter(assMesses.AsQueryable());

            res.Should().BeEmpty();
        }
        public void Filter_Supplier_ReturnsOwn()
        {
            var orgId = Guid.NewGuid().ToString();
            var ctx   = Creator.GetContext(orgId: orgId, role: Roles.Supplier);

            _context.Setup(c => c.HttpContext).Returns(ctx);
            var filter    = new AssessmentMessageFilter(_context.Object, _solutionDatastore.Object);
            var assMess1  = Creator.GetAssessmentMessage();
            var assMess2  = Creator.GetAssessmentMessage();
            var assMess3  = Creator.GetAssessmentMessage();
            var assMesses = new[] { assMess1, assMess2, assMess3 };
            var soln      = Creator.GetSolution(orgId: orgId);

            _solutionDatastore.Setup(x => x.ById(assMess1.SolutionId)).Returns(soln);

            var res = filter.Filter(assMesses.AsQueryable());

            res.Should().BeEquivalentTo(assMess1);
        }