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); }
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()); }
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"); }
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"); }