Beispiel #1
0
        public async void TerritoryID_Update_Valid_Reference()
        {
            Mock <ISalesPersonRepository> salesPersonRepository = new Mock <ISalesPersonRepository>();

            salesPersonRepository.Setup(x => x.GetSalesTerritory(It.IsAny <int>())).Returns(Task.FromResult <SalesTerritory>(new SalesTerritory()));

            var validator = new ApiSalesPersonRequestModelValidator(salesPersonRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiSalesPersonRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.TerritoryID, 1);
        }
Beispiel #2
0
        public async void TerritoryID_Create_Invalid_Reference()
        {
            Mock <ISalesPersonRepository> salesPersonRepository = new Mock <ISalesPersonRepository>();

            salesPersonRepository.Setup(x => x.SalesTerritoryByTerritoryID(It.IsAny <int>())).Returns(Task.FromResult <SalesTerritory>(null));

            var validator = new ApiSalesPersonRequestModelValidator(salesPersonRepository.Object);

            await validator.ValidateCreateAsync(new ApiSalesPersonRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.TerritoryID, 1);
        }