Beispiel #1
0
        public void MustBeSupplier_Supplier_Succeeds(string role)
        {
            _context.Setup(x => x.HttpContext).Returns(Creator.GetContext(role: role));
            var validator = new DummyValidatorBase(_context.Object, _logger.Object);
            var evidence  = Creator.GetEvidenceBase();

            validator.MustBeSupplier();
            var valres = validator.Validate(evidence);

            valres.Errors.Should().BeEmpty();
        }
Beispiel #2
0
        public void MustBeAdminOrSupplier_AdminSupplier_Succeeds(string role)
        {
            var ctx = Creator.GetContext(role: role);

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

            validator.MustBeAdminOrSupplier();
            var valres = validator.Validate(_context.Object);

            valres.Errors.Should().BeEmpty();
        }
Beispiel #3
0
        public void MustBeSupplier_NonSupplier_ReturnsError(string role)
        {
            _context.Setup(x => x.HttpContext).Returns(Creator.GetContext(role: role));
            var validator = new DummyValidatorBase(_context.Object, _logger.Object);
            var evidence  = Creator.GetEvidenceBase();

            validator.MustBeSupplier();
            var valres = validator.Validate(evidence);

            valres.Errors.Should()
            .ContainSingle(x => x.ErrorMessage == "Must be supplier")
            .And
            .HaveCount(1);
        }
Beispiel #4
0
        public void MustBeAdmin_NonAdmin_ReturnsError(string role)
        {
            var ctx = Creator.GetContext(role: role);

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

            validator.MustBeAdmin();
            var valres = validator.Validate(_context.Object);

            valres.Errors.Should()
            .ContainSingle(x => x.ErrorMessage == "Must be admin")
            .And
            .HaveCount(1);
        }