예제 #1
0
        public void EqualityAndInequality(
            string namespace1,
            string name1,
            string namespace2,
            string name2,
            bool shouldBeEqual)
        {
            // arrange
            var namespacedName1 = new NamespacedName(namespace1, name1);
            var namespacedName2 = new NamespacedName(namespace2, name2);

            // act
            var areEqual    = namespacedName1 == namespacedName2;
            var areNotEqual = namespacedName1 != namespacedName2;

#pragma warning disable CS1718 // Comparison made to same variable
            var sameEqual1    = namespacedName1 == namespacedName1;
            var sameNotEqual1 = namespacedName1 != namespacedName1;
            var sameEqual2    = namespacedName2 == namespacedName2;
            var sameNotEqual2 = namespacedName2 != namespacedName2;
#pragma warning restore CS1718 // Comparison made to same variable

            // assert
            areEqual.ShouldNotBe(areNotEqual);
            areEqual.ShouldBe(shouldBeEqual);
            sameEqual1.ShouldBeTrue();
            sameNotEqual1.ShouldBeFalse();
            sameEqual2.ShouldBeTrue();
            sameNotEqual2.ShouldBeFalse();
        }
예제 #2
0
        public void JustNameFromClusterResource()
        {
            // arrange
            var resource = new V1ClusterRole(
                apiVersion: V1ClusterRole.KubeApiVersion,
                kind: V1ClusterRole.KubeKind,
                metadata: new V1ObjectMeta(
                    name: "the-name"));

            // act
            var nn = NamespacedName.From(resource);

            // assert
            nn.Name.ShouldBe("the-name");
            nn.Namespace.ShouldBeNull();
        }
예제 #3
0
        public void NamespaceAndNameFromResource()
        {
            // arrange
            var resource = new V1ConfigMap(
                apiVersion: V1ConfigMap.KubeApiVersion,
                kind: V1ConfigMap.KubeKind,
                metadata: new V1ObjectMeta(
                    name: "the-name",
                    namespaceProperty: "the-namespace"));

            // act
            var nn = NamespacedName.From(resource);

            // assert
            nn.Name.ShouldBe("the-name");
            nn.Namespace.ShouldBe("the-namespace");
        }
예제 #4
0
        public void WorksAsDictionaryKey()
        {
            // arrange
            var dictionary = new Dictionary <NamespacedName, string>();
            var name1      = new NamespacedName("ns", "n1");
            var name2      = new NamespacedName("ns", "n2");
            var name3      = new NamespacedName("ns", "n3");

            // act
            dictionary[name1] = "one";
            dictionary[name1] = "one again";
            dictionary[name2] = "two";

            // assert
            dictionary.ShouldSatisfyAllConditions(
                () => dictionary.ShouldContainKeyAndValue(name1, "one again"),
                () => dictionary.ShouldContainKeyAndValue(name2, "two"),
                () => dictionary.ShouldNotContainKey(name3));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GroupKindNamespacedName"/> struct.
 /// </summary>
 /// <param name="group">The group.</param>
 /// <param name="kind">The kind.</param>
 /// <param name="namespacedName">Name of the namespaced.</param>
 public GroupKindNamespacedName(string group, string kind, NamespacedName namespacedName)
 {
     Group          = group;
     Kind           = kind;
     NamespacedName = namespacedName;
 }