public void WhenReferencesAreEquivalent_ThenGetHasCodeIsSame() { var ref1 = new MachineTypeLocator("proj", "zone", "n2d-standard-64"); var ref2 = new MachineTypeLocator("proj", "zone", "n2d-standard-64"); Assert.AreEqual(ref1.GetHashCode(), ref2.GetHashCode()); }
public void WhenCreatedFromPath_ThenToStringReturnsPath() { var path = "projects/project-1/zones/us-central1-a/machineTypes/n2d-standard-64"; Assert.AreEqual( path, MachineTypeLocator.FromString(path).ToString()); }
public void WhenPathInvalid_FromStringThrowsArgumentException() { Assert.Throws <ArgumentException>(() => MachineTypeLocator.FromString( "project-1/zones/us-central1-a/machineTypes/")); Assert.Throws <ArgumentException>(() => MachineTypeLocator.FromString( "project-1/zones/us-central1-a/machineTypes/ ")); Assert.Throws <ArgumentException>(() => MachineTypeLocator.FromString( "/")); }
public void WhenCreatedFromUrl_ThenToStringReturnsPath() { var path = "projects/project-1/zones/us-central1-a/machineTypes/n2d-standard-64"; Assert.AreEqual( path, MachineTypeLocator.FromString( "https://www.googleapis.com/compute/v1/" + path).ToString()); }
public void WhenReferencesAreEquivalent_ThenEqualsReturnsTrue() { var ref1 = new MachineTypeLocator("proj", "zone", "n2d-standard-64"); var ref2 = new MachineTypeLocator("proj", "zone", "n2d-standard-64"); Assert.IsTrue(ref1.Equals(ref2)); Assert.IsTrue(ref1.Equals((object)ref2)); Assert.IsTrue(ref1 == ref2); Assert.IsFalse(ref1 != ref2); }
public void WhenUsingBetaApi_FromStringReturnsObject() { var ref1 = MachineTypeLocator.FromString( "https://compute.googleapis.com/compute/beta/projects/project-1/zones/us-central1-a/machineTypes/n2d-standard-64"); Assert.AreEqual("machineTypes", ref1.ResourceType); Assert.AreEqual("n2d-standard-64", ref1.Name); Assert.AreEqual("us-central1-a", ref1.Zone); Assert.AreEqual("project-1", ref1.ProjectId); }
public void WhenPathIsValid_FromStringReturnsObject() { var ref1 = MachineTypeLocator.FromString( "projects/project-1/zones/us-central1-a/machineTypes/n2d-standard-64"); Assert.AreEqual("machineTypes", ref1.ResourceType); Assert.AreEqual("n2d-standard-64", ref1.Name); Assert.AreEqual("us-central1-a", ref1.Zone); Assert.AreEqual("project-1", ref1.ProjectId); }
public void TestEqualsNull() { var ref1 = new MachineTypeLocator("proj", "zone", "n2d-standard-64"); Assert.IsFalse(ref1.Equals(null)); Assert.IsFalse(ref1.Equals((object)null)); Assert.IsFalse(ref1 == null); Assert.IsFalse(null == ref1); Assert.IsTrue(ref1 != null); Assert.IsTrue(null != ref1); }
public void WhenPathLacksProject_FromStringThrowsArgumentException() { Assert.Throws <ArgumentException>(() => MachineTypeLocator.FromString( "project-1/zones/us-central1-a/machineTypes/n2d-standard-64")); }