Exemplo n.º 1
0
        public void TransposeTest()
        {
            BitArray[] x = new BitArray[3]
            {
                new BitArray(new bool[3] {
                    true, true, false
                }),
                new BitArray(new bool[3] {
                    false, false, true
                }),
                new BitArray(new bool[3] {
                    true, true, false
                })
            };
            var y = BitsetHelper.transpose(x);

            x = new BitArray[3]
            {
                new BitArray(new bool[3] {
                    true, false, true
                }),
                new BitArray(new bool[3] {
                    true, false, true
                }),
                new BitArray(new bool[3] {
                    false, true, false
                })
            };
            BitArrayComparer bComp = new BitArrayComparer();

            for (int i = 0; i < 3; ++i)
            {
                Assert.IsTrue(bComp.Equals(x[i], y[i]));
            }
        }
Exemplo n.º 2
0
        public List <BitArray> GetDistinctOutputs()
        {
            List <BitArray>  distinctOutputs = new List <BitArray>();
            BitArrayComparer comparer        = new BitArrayComparer();

            foreach (DataItem item in Items)
            {
                bool itemExsist = false;

                foreach (BitArray distinctItem in distinctOutputs)
                {
                    if (comparer.Equals(item.Outputs, distinctItem))
                    {
                        itemExsist = true;
                        break;
                    }
                }

                if (!itemExsist)
                {
                    distinctOutputs.Add(item.Outputs);
                }
            }

            return(distinctOutputs);
        }
Exemplo n.º 3
0
        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");
        }