public void Can_check_used_disk_per_store() { CloudInfrastructure cloud = new CloudInfrastructure(); cloud.CreateStore("myImages"); cloud.UploadDocument("myImages", "picture.jpeg"); // we suppose all documents have the same size which is 0.1gb Assert.AreEqual(0.100, cloud.UsedDiskStore("myImages"), 0.00001); cloud.UploadDocument("myImages", "profile.png"); // a second document was inserted, used disk in "muImages" = 200mb Assert.AreEqual(0.200, cloud.UsedDiskStore("myImages"), 0.00001); }
public void can_create_multiple_stores_in_cloud() { CloudInfrastructure cloud = new CloudInfrastructure(); cloud.CreateStore("myFiles"); cloud.CreateStore("myImages"); cloud.UploadDocument("myImages", "picture.jpeg", "profile.png"); Assert.AreEqual("myFiles:empty||myImages:picture.jpeg, profile.png", cloud.ListStores()); }
public void can_check_aggregated_data_for_all_machines_and_stores() { CloudInfrastructure cloud = new CloudInfrastructure(); cloud.CreateMachine("machine1", "Linux", "50gb", "8gb"); cloud.CreateMachine("machine2", "Windows", "20gb", "4gb"); Assert.AreEqual("machine1:Inactive||machine2:Inactive", cloud.ListMachines()); // globalUsedDisk method should return the used disk of all machines and stores existing in the cloud // for now 2 machines exists, with 50gb and 20gb disk sizes = 70gb Assert.AreEqual(70, cloud.GlobalUsedDisk(), 0.00001); // machines are inactive, no memory is used Assert.AreEqual(0, cloud.GlobalUsedMemory(), 0.00001); cloud.StartMachine("machine1"); Assert.AreEqual(70, cloud.GlobalUsedDisk(), 0.00001); Assert.AreEqual(8, cloud.GlobalUsedMemory(), 0.00001); cloud.StartMachine("machine2"); Assert.AreEqual(70, cloud.GlobalUsedDisk(), 0.00001); Assert.AreEqual(12, cloud.GlobalUsedMemory(), 0.00001); cloud.CreateStore("myImages"); cloud.UploadDocument("myImages", "picture.jpeg"); // 2 machines and 1 documents now exists in the cloud Assert.AreEqual(70.100, cloud.GlobalUsedDisk(), 0.00001); Assert.AreEqual(12, cloud.GlobalUsedMemory(), 0.00001); cloud.UploadDocument("myImages", "profile.png"); Assert.AreEqual(70.200, cloud.GlobalUsedDisk(), 0.00001); Assert.AreEqual(12, cloud.GlobalUsedMemory(), 0.00001); cloud.StopMachine("machine1"); Assert.AreEqual(70.200, cloud.GlobalUsedDisk(), 0.00001); Assert.AreEqual(4, cloud.GlobalUsedMemory(), 0.00001); cloud.EmptyStore("myImages"); Assert.AreEqual(70, cloud.GlobalUsedDisk(), 0.00001); Assert.AreEqual(4, cloud.GlobalUsedMemory(), 0.00001); }
public void Can_create_a_store_in_cloud() { // This is the main CloudInfrastructure class. You will need to put your code there. // The CloudInfrastructure class can also call other classes that you can create if needed. CloudInfrastructure cloud = new CloudInfrastructure(); cloud.CreateStore("myFiles"); cloud.UploadDocument("myFiles", "book.pdf"); Assert.AreEqual("myFiles:book.pdf", cloud.ListStores()); // make sure the cloud.listStores() method return the expected output }
public void Can_delete_and_empty_stores_in_cloud() { CloudInfrastructure cloud = new CloudInfrastructure(); cloud.CreateStore("myFiles"); cloud.CreateStore("myImages"); cloud.UploadDocument("myImages", "picture.jpeg", "profile.png"); cloud.DeleteStore("myFiles"); // delete a store Assert.AreEqual("myImages:picture.jpeg, profile.png", cloud.ListStores()); cloud.EmptyStore("myImages"); // empty a store Assert.AreEqual("myImages:empty", cloud.ListStores()); // an empty store is display as "empty" }