public void AddResource_AddADuplicateResourcePath_ShouldReturnHandle() { var resourceManager = new ResourceManager(); var fileInfo = new FileInfo ("c:/this/is/a/test"); var fileInfoDuplicate = new FileInfo ("c:/this/is/a/test"); var handle = resourceManager.AddResource (fileInfo); var count = resourceManager.ResourceCount; Assert.That (resourceManager.AddResource (fileInfoDuplicate), Is.EqualTo (handle)); Assert.That (count, Is.EqualTo (resourceManager.ResourceCount)); }
public void AddResources_AddManyResources_ShouldSucceed() { var resources = new[] { new FileInfo ("c:/this/is/a/test"), (FileSystemInfo) new DirectoryInfo ("c:/this/is/a/test/dir"), new FileInfo ("c:/this/is/another/test"), new FileInfo ("c:/this/is/yet/another/test"), }; var resourceManager = new ResourceManager(); Assert.That (() => resourceManager.AddResources (resources), Is.InstanceOf<ResourceHandle[]>()); Assert.That (resourceManager.ResourceCount, Is.EqualTo (resources.Length)); }
public void AddResources_AddDuplicateResources_ShouldThrowInvalidOperation() { var resourceManager = new ResourceManager(); var resources = new[] { new FileInfo ("c:/this/is/a/test"), (FileSystemInfo) new DirectoryInfo ("c:/this/is/a/test/dir"), new FileInfo ("c:/this/is/another/test"), new FileInfo ("c:/this/is/yet/another/test"), }; var handles = resourceManager.AddResources (resources); var count = resourceManager.ResourceCount; Assert.That ( resourceManager.AddResources (resources), Is.EquivalentTo (handles)); Assert.That (count, Is.EqualTo (resourceManager.ResourceCount)); }
public void RemoveResource_RemoveByValidHandle_ShouldSucceed() { var resourceManager = new ResourceManager(); var count = resourceManager.ResourceCount; var resourceHandle = resourceManager.AddResource (new FileInfo ("c:/this/is/a/test")); Assert.That (() => resourceManager.RemoveResource (resourceHandle), Throws.Nothing); Assert.That (count, Is.EqualTo (resourceManager.ResourceCount)); }
public void GetResource_GetByValidHandle_ShouldSucceed() { var resourceManager = new ResourceManager(); var resourceHandle = resourceManager.AddResource (new FileInfo ("c:/this/is/a/test")); Assert.That (() => resourceManager.GetResource (resourceHandle), Throws.Nothing); }
public void GetResource_GetByInvalidHandle_ShouldThrowInvalidOperation() { var resourceManager = new ResourceManager(); var resourceHandle = new ResourceHandle (Guid.NewGuid()); Assert.That ( () => resourceManager.GetResource (resourceHandle), Throws.InvalidOperationException.With.Message.EqualTo (string.Format ("Resource {0} not found.", resourceHandle))); }
public void AddResource_AddAResource_ShouldSucceed() { var resourceManager = new ResourceManager(); Assert.That (() => resourceManager.AddResource (new FileInfo ("c:/this/is/a/test")), Is.InstanceOf<ResourceHandle>()); Assert.That (() => resourceManager.AddResource (new DirectoryInfo ("c:/this/is/a/test/dir")), Is.InstanceOf<ResourceHandle>()); }