Exemplo n.º 1
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.º 2
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.º 3
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.º 4
0
        public void TestThatCanAddStorageThrowsArgumentNullExceptionWhenStorageIsNull()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

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

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.CanAddStorage(null, new List <IStorage>(0)));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "storage");
        }