public void Provider_Should_Create_Linux_VirtualMachine_Infrastructure_Json_File() { //Arrang int cpu = 8; int ram = 4; int hdd = 40; LinuxDistribution linuxDistribution = LinuxDistribution.Suse; var expectedObject = new VirtualMachineResource { CPU = cpu, HardDisk = hdd, RAM = ram, OperatingSystem = linuxDistribution.ToString() }; var fileSystemMock = new Mock <IFileManager>(); fileSystemMock.Setup(w => w.WriteJsonFile(It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>())) .Verifiable(); //Act var provider = new Providers.Provider(_providerName, fileSystemMock.Object); var infra = provider.CreateInfrastructure("UAT"); infra.VirtualMachine(new Linux(linuxDistribution), hdd, ram, cpu); //Assert fileSystemMock.Verify(mock => mock.WriteJsonFile(It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once()); fileSystemMock.Verify(mock => mock.WriteJsonFile(expectedObject, @"c:\test\UAT\VirtualMachine", "UAT_Server.json"), Times.Once()); }
public void VirtualMachine_Should_Set_Linux_VirtualMachineResource_Correctly() { //Arrang int cpu = 8; int ram = 4; int hdd = 40; LinuxDistribution LinuxDist = LinuxDistribution.Debian; var fileSystemMock = new Mock <IFileManager>(); fileSystemMock.Setup(w => w.WriteJsonFile(It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>())) .Verifiable(); string providerPath = @"D:\IGS"; var expected = @"UAT_Server.json"; //Act var actual = new Infrastructure("UAT", providerPath, fileSystemMock.Object) .VirtualMachine(new Linux(LinuxDist), hdd, ram, cpu); //Assert Assert.AreEqual(expected, actual); }
public void Build_Linux_VirtualMachine_with_Right_Object() { //Arrange int cpu = 8; int ram = 4; int hdd = 40; LinuxDistribution linuxDistribution = LinuxDistribution.Debian; var vm = new VirtualMachine(new Linux(linuxDistribution), hdd, ram, cpu); var excepted = new VirtualMachineResource { CPU = 8, HardDisk = 40, RAM = 4, OperatingSystem = "Debian" }; //Act var action = vm.Build(); //Assert Assert.AreEqual(excepted, action); }
public Linux(LinuxDistribution distribution) { _distribution = distribution; }