Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        public void WhenCreatedFromPath_ThenToStringReturnsPath()
        {
            var path = "projects/project-1/zones/us-central1-a/machineTypes/n2d-standard-64";

            Assert.AreEqual(
                path,
                MachineTypeLocator.FromString(path).ToString());
        }
Esempio n. 3
0
 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(
                                           "/"));
 }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
 public void WhenPathLacksProject_FromStringThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => MachineTypeLocator.FromString(
                                           "project-1/zones/us-central1-a/machineTypes/n2d-standard-64"));
 }