BalancingOneServerWithSomeCapacityAndVmWithLesserOrEqualSizeThanServerCapacityFillsTheServerWithTheVm( Server server, Vm vm, double expectedPercentage) { Balance(AListOfServersWith(server), AListOfVms(vm)); Assert.That(server, HasLoadPercentageOf(expectedPercentage)); Assert.That(server.Vms, Has.Item(EqualTo(vm))); }
public void Describe_mismatch() { var matcher = Has.Item(Is.EqualTo("aaa")); var description = new StringDescription(); matcher.DescribeMismatch(new [] { "bbb", "ddd" }, description); Assert.That(description.ToString(), Is.EqualTo("was \"bbb\", was \"ddd\"")); }
public void Describe_to_appends_matcher_description() { var matcher = Has.Item(Is.EqualTo("aaa")); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("a collection containing \"aaa\"")); }
public void IfServerHasNotEnoughPlaceToFitAnotherVmItShouldHaveTheSameLoadRateAfterBalancing() { var serverWithSomeLargeVm = A(Server().WithCapacity(10).Having(A(Vm().WithSize(9)))); var tooLargeVm = A(Vm().WithSize(5)); Balance(AListOfServersWith(serverWithSomeLargeVm), AListOfVms(tooLargeVm)); Assert.That(serverWithSomeLargeVm.Vms, Not(Has.Item(EqualTo(tooLargeVm)))); Assert.That(serverWithSomeLargeVm, HasLoadPercentageOf(90.0)); }
public void BalancingOneServerWithOneSlotCapacityAndOneSlotVmFillsTheServerWithTheVm() { var server = A(Server().WithCapacity(1)); var vm = A(Vm().WithSize(1)); Balance(AListOfServersWith(server), AListOfVms(vm)); Assert.That(server, HasLoadPercentageOf(100.0)); Assert.That(server.Vms, Has.Item(EqualTo(vm))); }
IfTwoServersAreProvidedAndOnlyOneMachineIsAvailableToAssignTheServerWithTheLesserLoadRateShouldReceiveVm() { var serverWithSomeVm = A(Server().WithCapacity(10).Having(A(Vm().WithSize(2)))); var emptyServer = A(Server().WithCapacity(10)); var vmToBalance = A(Vm().WithSize(5)); Balance(AListOfServersWith(serverWithSomeVm, emptyServer), AListOfVms(vmToBalance)); Assert.That(serverWithSomeVm.Vms, Not(Has.Item(EqualTo(vmToBalance)))); Assert.That(emptyServer.Vms, Has.Item(EqualTo(vmToBalance))); Assert.That(emptyServer, HasLoadPercentageOf(50.0)); Assert.That(serverWithSomeVm, HasLoadPercentageOf(20.0)); }
public void ServerWithLargeCapacityShouldContainAllProvidedVMsAfterBalancingAndHaveSpecifiedLoadPercentageRate() { var server = A(Server().WithCapacity(20)); var(vm1, vm2, vm3, vm4, vm5) = (A(Vm().WithSize(2)), A(Vm().WithSize(3)), A(Vm().WithSize(1)), A(Vm().WithSize(5)), A(Vm().WithSize(4))); Balance(AListOfServersWith(server), AListOfVms(vm1, vm2, vm3, vm4, vm5)); var vms = server.Vms; Assert.That(vms, Has.Item(EqualTo(vm1))); Assert.That(vms, Has.Item(EqualTo(vm2))); Assert.That(vms, Has.Item(EqualTo(vm3))); Assert.That(vms, Has.Item(EqualTo(vm4))); Assert.That(vms, Has.Item(EqualTo(vm5))); Assert.That(server, HasLoadPercentageOf(75.0)); }
public void Has_item() { Assert.That(new[] { "aaa", "bbb", "ccc" }, Has.Item(Is.EqualTo("aaa"))); }
public void Has_item_with_matcher() { var elementMatcher = new CustomMatcher <string>("aaa", s => s == "aaa"); Assert.That(new[] { "aaa", "bbb", "ccc" }, Has.Item <string>(elementMatcher)); }