Ejemplo n.º 1
0
        public void Setup()
        {
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":1:Text:1", "Basic String is valid"));
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":2:Text:2", "Basic String is valid"));
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":3:Text:3", "Basic String is valid"));
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":4:Text:4", "Basic String is valid"));
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":5:Text:5", "Basic String is valid"));
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":6:Text:6", "Basic String is valid"));
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":7:Text:7", "Basic String is valid"));
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":8:Text:8", "Basic String is valid"));
            validDiscoveries.Add(new Tuple <string, string>(Discovery.TAG + ":9:Text:9", "Basic String is valid"));

            String temp = DiscoveryCatalogue.TAG;

            foreach (var disc in validDiscoveries)
            {
                temp += "#" + disc.Item1;
            }

            dc = new DiscoveryCatalogue(temp);

            validStrings.Add(new Tuple <string, string>(DiscoveryModel.DISCOVERED_TAG, "Empty discovered is valid"));
            validStrings.Add(new Tuple <string, string>(DiscoveryModel.DISCOVERED_TAG + ":1", "One discovery is valid"));
            validStrings.Add(new Tuple <string, string>(DiscoveryModel.DISCOVERED_TAG + ":1:2:3:4:5:6:7:8", "Mulitple discoveries are valid"));

            invalidStrings.Add(new Tuple <string, string>(DiscoveryModel.DISCOVERED_TAG + ":", "If there are discoveries there should be at least one"));
            invalidStrings.Add(new Tuple <string, string>(DiscoveryModel.DISCOVERED_TAG + ":1:1", "Discoveries should be unique"));
            invalidStrings.Add(new Tuple <string, string>(DiscoveryModel.DISCOVERED_TAG + ":a", "Discoveries should be ints"));
            invalidStrings.Add(new Tuple <string, string>(DiscoveryModel.DISCOVERED_TAG + ":-1", "Discoveries should be positive"));
        }
Ejemplo n.º 2
0
        public void DiscoveryCatalogue_IsValidDiscoveryCatalogue()
        {
            foreach (Tuple <String, String> test in validStrings)
            {
                Assert.IsTrue(DiscoveryCatalogue.IsValidDiscoveryCatalogue(test.Item1), test.Item2);
            }

            foreach (Tuple <String, String> test in invalidStrings)
            {
                Assert.IsFalse(DiscoveryCatalogue.IsValidDiscoveryCatalogue(test.Item1), test.Item2);
            }
        }
Ejemplo n.º 3
0
        public void DiscoveryCatalogue_ParseToString()
        {
            int i = 1;

            foreach (Tuple <String, String> test in validStrings)
            {
                DiscoveryCatalogue dc       = new DiscoveryCatalogue(test.Item1);
                String             expected = test.Item1;

                Assert.AreEqual(expected, dc.ParseToString(), "Strings should match for catalogue " + i);
                i++;
            }
        }
Ejemplo n.º 4
0
        public void DiscoveryCatalogue_ParseFromString()
        {
            int i = 1;
            List <Discovery> validDisc = new List <Discovery>();

            foreach (var test in validDiscoveries)
            {
                validDisc.Add(new Discovery(test.Item1));
            }

            foreach (Tuple <String, String> test in validStrings)
            {
                DiscoveryCatalogue dc = new DiscoveryCatalogue(test.Item1);
                var discoveries       = dc.GetDiscoveries().Values;

                switch (i)
                {
                case 1:
                    Assert.AreEqual(0, discoveries.Count, "Catalogue should be empty");
                    break;

                case 2:
                    Assert.AreEqual(1, discoveries.Count, "Catalogue should have one item");
                    break;

                case 3:
                    Assert.AreEqual(2, discoveries.Count, "Catalogue should have 2 items");
                    break;

                case 4:
                    Assert.AreEqual(9, discoveries.Count, "Catalogue should have 9 empty");
                    break;
                }

                int j = 0;
                foreach (Discovery disc in discoveries)
                {
                    Assert.AreEqual(disc.ParseToString(), validDisc[j].ParseToString(), "Discoveries should be equal");
                    j++;
                }
                i++;
            }
        }