Exemplo n.º 1
0
        public void TestThatCreateInitializeDomainObjectValidations()
        {
            IDomainObjectValidations domainObjectValidations = DomainObjectValidations.Create();

            Assert.That(domainObjectValidations, Is.Not.Null);
            Assert.That(domainObjectValidations, Is.TypeOf <DomainObjectValidations>());
        }
Exemplo n.º 2
0
        public void TestThatCanRemoveStorageThrowsArgumentNullExceptionWhenStorageIsNull()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.CanRemoveStorage(null));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "storage");
        }
Exemplo n.º 3
0
        public void TestThatGetHouseholdLimitReturnsActualHouseholdLimit(Membership membership, int householdLimit)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            int result = sut.GetHouseholdLimit(membership);

            Assert.That(result, Is.EqualTo(householdLimit));
        }
Exemplo n.º 4
0
        public void TestThatCanAddStorageThrowsArgumentNullExceptionWhenExistingStorageCollectionIsNull()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.CanAddStorage(BuildStorageMock(), null));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "existingStorageCollection");
        }
Exemplo n.º 5
0
        public void TestThatIsMailAddressThrowsArgumentNullExceptionWhenMailAddressIsNullEmptyOrWhiteSpace(string validMailAddress)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.IsMailAddress(validMailAddress));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "value");
        }
Exemplo n.º 6
0
        public void TestThatInRangeValidatesWhetherValueIsInRange(int value, int startValue, int endValue, bool expectedResult)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            bool result = sut.InRange(value, new Range <int>(startValue, endValue));

            Assert.That(result, Is.EqualTo(expectedResult));
        }
Exemplo n.º 7
0
        public void TestThatInRangeThrowsArgumentNullExceptionWhenRangeIsNull()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.InRange(_fixture.Create <int>(), null));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "range");
        }
Exemplo n.º 8
0
        public void TestThatCanUpgradeMembershipValidatesWhetherMembershipCanBeUpgraded(Membership currentMembership, Membership upgradeToMembership, bool expectedResult)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            bool result = sut.CanUpgradeMembership(currentMembership, upgradeToMembership);

            Assert.That(result, Is.EqualTo(expectedResult));
        }
Exemplo n.º 9
0
        public void TestThatHasRequiredMembershipValidatesWhetherMembershipMatchesRequiredMembership(Membership membership, Membership requiredMembership, bool expectedResult)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            bool result = sut.HasRequiredMembership(membership, requiredMembership);

            Assert.That(result, Is.EqualTo(expectedResult));
        }
Exemplo n.º 10
0
        public void TestThatHasReachedHouseholdLimitValidatesWhetherHouseholdLimitHasBeenReached(Membership membership, int numberOfHouseholds, bool expectedResult)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            bool result = sut.HasReachedHouseholdLimit(membership, numberOfHouseholds);

            Assert.That(result, Is.EqualTo(expectedResult));
        }
Exemplo n.º 11
0
        public void TestThatIsMailAddressReturnsFalseForInvalidMailAddress(string validMailAddress)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            bool result = sut.IsMailAddress(validMailAddress);

            Assert.That(result, Is.False);
        }
Exemplo n.º 12
0
        public void TestThatCanRemoveStorageCallsStorageTypeOnStorageToValidate()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorage storageMock = BuildStorageMock();

            sut.CanRemoveStorage(storageMock);

            storageMock.AssertWasCalled(m => m.StorageType, opt => opt.Repeat.Once());
        }
Exemplo n.º 13
0
        public void TestThatCanRemoveStorageReturnsTrueWhenStorageDoesNotHaveStorageType()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorage storageMock = BuildStorageMock(false);

            bool result = sut.CanRemoveStorage(storageMock);

            Assert.That(result, Is.True);
        }
Exemplo n.º 14
0
        public void TestThatGetHouseholdLimitReturnsHouseholdLimitForEachMembership()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            foreach (Membership membershipToTest in Enum.GetValues(typeof(Membership)).Cast <Membership>())
            {
                int result = sut.GetHouseholdLimit(membershipToTest);
                Assert.That(result, Is.GreaterThan(0));
            }
        }
Exemplo n.º 15
0
        public void TestThatCanRemoveStorageReturnsDeletableFromStorageTypeWhenStorageDoesHaveCreatableStorageType(bool deletable)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorageType storageTypeMock = BuildStorageTypeMock(StorageType.IdentifierForRefrigerator, deletable: deletable);
            IStorage     storageMock     = BuildStorageMock(storageType: storageTypeMock);

            bool result = sut.CanRemoveStorage(storageMock);

            Assert.That(result, Is.EqualTo(deletable));
        }
Exemplo n.º 16
0
        public void TestThatCanRemoveStorageCallsDeletableOnStorageTypeWhenStorageDoesHaveStorageType()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorageType storageTypeMock = BuildStorageTypeMock(StorageType.IdentifierForRefrigerator);
            IStorage     storageMock     = BuildStorageMock(storageType: storageTypeMock);

            sut.CanRemoveStorage(storageMock);

            storageTypeMock.AssertWasCalled(m => m.Deletable, opt => opt.Repeat.Once());
        }
Exemplo n.º 17
0
        public void TestThatCanAddStorageCallsStorageTypeOnStorageToValidate()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorage storageMock = BuildStorageMock();
            IEnumerable <IStorage> existingStorageCollection = new List <IStorage>
            {
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForRefrigerator)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForFreezer)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForKitchenCabinets)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForShoppingBasket))
            };

            sut.CanAddStorage(storageMock, existingStorageCollection);

            storageMock.AssertWasCalled(m => m.StorageType, opt => opt.Repeat.Once());
        }
Exemplo n.º 18
0
        public void TestThatCanAddStorageReturnsTrueWhenStorageDoesHaveNonCreatableStorageTypeAndExistingStorageCollectionDoesNotContainStorageOfStorageType()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorageType           storageTypeMock           = BuildStorageTypeMock(StorageType.IdentifierForRefrigerator, false);
            IStorage               storageMock               = BuildStorageMock(storageType: storageTypeMock);
            IEnumerable <IStorage> existingStorageCollection = new List <IStorage>
            {
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForFreezer)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForKitchenCabinets)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForShoppingBasket))
            };

            bool result = sut.CanAddStorage(storageMock, existingStorageCollection);

            Assert.That(result, Is.True);
        }
Exemplo n.º 19
0
        public void TestThatConstructorInitializeDomainObjectValidations()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);
        }