public void ReachMatrixTest_NSOnly() { Pod[] pods = new Pod[4] { new Pod(), new Pod(), new Pod("ns1"), new Pod("ns1") }; pods[0].addLabel("k0", "v0"); pods[1].addLabel("k1", "v1"); pods[2].addLabel("k2", "v2"); pods[3].addLabel("k3", "v3"); Namespace[] namespaces = new Namespace[2] { new Namespace("default"), new Namespace("ns1") }; namespaces[0].addLabel("k0", "v0"); namespaces[1].addLabel("k1", "v1"); Policy[] polices = new Policy[] { new Policy(), new Policy("ns1") }; polices[0].selectLabels = new Dictionary <string, string>() { { "k0", "v0" } }; polices[0].allowNamespaces = new Dictionary <string, string>() { { "k1", "v1" } }; polices[1].selectLabels = new Dictionary <string, string>() { { "k2", "v2" } }; polices[1].allowNamespaces = new Dictionary <string, string>() { { "k0", "v0" } }; KanoVerifier verifier = new KanoVerifier(); var reachMatrix = verifier.createReachMatrix(pods, polices, namespaces); Assert.AreEqual(reachMatrix.Length, 4, "reach matrix should be 4*4"); BitArrayComparer bComp = new BitArrayComparer(); Assert.IsTrue(bComp.Equals(reachMatrix[0], new BitArray(new bool[4] { false, false, true, true })), "pod0 has wrong reachability"); Assert.IsTrue(bComp.Equals(reachMatrix[1], new BitArray(new bool[4] { true, true, false, false })), "pod1 has wrong reachability"); Assert.IsTrue(bComp.Equals(reachMatrix[2], new BitArray(new bool[4] { true, true, false, false })), "pod2 has wrong reachability"); Assert.IsTrue(bComp.Equals(reachMatrix[3], new BitArray(new bool[4] { false, false, true, true })), "pod3 has wrong reachability"); }
public void NsPodsMapTests() { KanoVerifier verifier = new KanoVerifier(); Pod p1 = new Pod("default"); Pod p2 = new Pod("ns1"); Pod p3 = new Pod("ns2"); Pod p4 = new Pod("ns2"); var output = verifier.createNSMatrix(new Pod[] { p1, p2, p3, p4 }); var actual = new Dictionary <string, BitArray>() { { "default", new BitArray(new bool[4] { true, false, false, false }) }, { "ns1", new BitArray(new bool[4] { false, true, false, false }) }, { "ns2", new BitArray(new bool[4] { false, false, true, true }) }, }; Assert.IsTrue(new DictionaryComparer <string, BitArray>(new BitArrayComparer()).Equals(output, actual)); }