Esempio n. 1
0
        public void RegexContainer_InvalidEnumValue_InvalidContainerReturned()
        {
            string val = "2";
            RegexContainer <EnumTest>  container = new RegexContainer <EnumTest>();
            ContainerResult <EnumTest> result    = container.Parse(val);

            Assert.That(result.Success, Is.False);
        }
Esempio n. 2
0
        public void RegexContainer_ValidEnumName_ContainerCreated()
        {
            string name = "Test1";
            RegexContainer <EnumTest>  container = new RegexContainer <EnumTest>();
            ContainerResult <EnumTest> result    = container.Parse(name);

            Assert.That(result.Value.Value, Is.EqualTo(TestEnum.Test1));
        }
Esempio n. 3
0
        public void RegexContainer_ValidEnumValue_ContainerCreated()
        {
            string val = "1";
            RegexContainer <EnumTest>  container = new RegexContainer <EnumTest>();
            ContainerResult <EnumTest> result    = container.Parse(val);

            Assert.That(result.Value.Value, Is.EqualTo(TestEnum.Test2));
        }
Esempio n. 4
0
        public void RegexContainer_DataMismatch_InvalidContainerReturned()
        {
            string text = "Fail";
            RegexContainer <DataMismatch>  container = new RegexContainer <DataMismatch>();
            ContainerResult <DataMismatch> result    = container.Parse(text);

            Assert.That(result.Success, Is.False);
        }
Esempio n. 5
0
        public void RegexContainer_ReloadMetadata_ValidMetadataLoaded()
        {
            string val = "1";
            RegexContainer <MetadataTest> container = new RegexContainer <MetadataTest>();

            RegexContainer <MetadataTest> .ClearMetadata();

            RegexContainer <MetadataTest> .LoadMetadata();

            ContainerResult <MetadataTest> result = container.Parse(val);

            Assert.That(result.Value.X, Is.EqualTo(1));
        }
Esempio n. 6
0
 public void RegexContainer_NonWriteableProperty_DataException()
 {
     try
     {
         RegexContainer <NonWriteableProperty> container = new RegexContainer <NonWriteableProperty>();
     }
     catch (TypeInitializationException ex) when(ex.InnerException is InvalidRegexDataException)
     {
         Assert.Pass();
         return;
     }
     Assert.Fail();
 }
Esempio n. 7
0
        public void RegexContainer_ParseAllArrayType_ValidContainersReturned()
        {
            string names = "John Doe, Jane Doe";
            RegexContainer <NamesTest>  container = new RegexContainer <NamesTest>();
            ContainerResult <NamesTest> result    = container.Parse(names);

            Assert.Multiple(() =>
            {
                Assert.That(result.Success, Is.True);
                Assert.That(result.Value.Names[0], Is.EqualTo("John Doe"));
                Assert.That(result.Value.Names[1], Is.EqualTo("Jane Doe"));
            });
        }
Esempio n. 8
0
        public void RegexContainer_ParseDefaultGrouping_ValidContainerReturned()
        {
            string points = "1 10 7";
            RegexContainer <DefaultGroupingTest>  container = new RegexContainer <DefaultGroupingTest>();
            ContainerResult <DefaultGroupingTest> result    = container.Parse(points);

            Assert.Multiple(() =>
            {
                Assert.That(result.Success, Is.True);
                Assert.That(result.Value.X, Is.EqualTo(1));
                Assert.That(result.Value.Y, Is.EqualTo(10));
                Assert.That(result.Value.Z, Is.EqualTo(7));
            });
        }
Esempio n. 9
0
        public void RegexContainer_ParseAllCollectionType_ValidContainersReturned()
        {
            string userInfoData =
                "John Doe, 1500 St. Martin Blvd, Blah, XX 11111|23 X Pkwy, Test Blank, YY 44444\nJane Doe, 43 Test Dr. Apt#1, Test, YY 33333";
            RegexContainer <UserInfo>            container = new RegexContainer <UserInfo>();
            ContainerResultCollection <UserInfo> results   = container.ParseAll(userInfoData);

            Assert.Multiple(() =>
            {
                foreach (UserInfo result in results)
                {
                    Assert.That(result.LastName, Is.EqualTo("Doe"));
                }
            });
        }
Esempio n. 10
0
        public void RegexContainer_Parse_ValidContainerReturned()
        {
            RegexContainer <UserInfo> container = new RegexContainer <UserInfo>();
            string text = "John Doe, 1500 St. Martin Blvd, Blah, XX 11111|23 X Pkwy, Test Blank, YY 44444\r\n";
            ContainerResult <UserInfo> result = container.Parse(text);

            Assert.Multiple(() =>
            {
                Assert.That(result.Success, Is.True);
                Assert.That(result.Value.FirstName, Is.EqualTo("John"));
                Assert.That(result.Value.LastName, Is.EqualTo("Doe"));
                Assert.That(result.Value.Addresses[0].City, Is.EqualTo("Blah"));
                Assert.That(result.Value.Addresses[0].State, Is.EqualTo("XX"));
                Assert.That(result.Value.Addresses[1].StreetAddress, Is.EqualTo("23 X Pkwy"));
                Assert.That(result.Value.Addresses[1].ZipCode, Is.EqualTo(44444));
            });
        }
Esempio n. 11
0
 /// <summary>
 /// Creates a Language instance with the given memory
 /// </summary>
 /// <param name="_memorySize">How much memory is needed</param>
 public Language(int _memorySize)
 {
     DestinationSelecter = new RegexContainer();
     CommandStackCarry   = new Stack <int>();
     TypeAliasContainer  = new SelfTypes();
     Memory            = new char[_memorySize];
     Memory            = Memory.Select((s) => '\\').ToArray();
     RegisterInterrupt = new List <Action>();
     Ram         = new List <Variable>();
     CommandList = new Dictionary <string, Action>();
     CommandList.Add("j", () => JumpCommand(_pointer));           //Jump
     CommandList.Add("p", () => PopOrPush(_pointer));             //pop is 0 or push that is 1
     CommandList.Add("i", () => Interrupt(_pointer));             //Interrupt n
     CommandList.Add("s", () => SetCarry(_pointer));              //Set value carry
     CommandList.Add("n", () => WriteValueCarry());               //Write value carry in logger
     CommandList.Add("m", () => Move(_pointer + 2));              //Move&Here;what
     CommandList.Add("a", () => Add(_pointer));                   //Add here;so_much
     CommandList.Add("\\", () => _pointer = int.MaxValue - 1);    //End of program
 }
Esempio n. 12
0
        public void RegexContainer_BulkCreation(int amount)
        {
            RegexContainer <Triangle> container = new RegexContainer <Triangle>();
            List <string>             triangles = CreatePointGroups(amount, 3);

            bool overallSuccess = true;

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            foreach (string triangle in triangles)
            {
                if (!container.Parse(triangle).Success)
                {
                    overallSuccess = false;
                }
            }
            sw.Stop();
            Console.WriteLine($"Elapsed Ms: {sw.ElapsedMilliseconds}");
            Assert.That(overallSuccess, Is.True);
        }
Esempio n. 13
0
        public void RegexContainer_DataMismatchWithSubContainer_InvalidContainerReturned()
        {
            RegexContainer <DataMismatchSubcontainer> container = new RegexContainer <DataMismatchSubcontainer>();

            Assert.That(container.Parse("Fail").Success, Is.False);
        }
Esempio n. 14
0
        public void RegexContainer_ValidContainer_Created()
        {
            RegexContainer <ValidContainer> container = new RegexContainer <ValidContainer>();

            Assert.That(container, Is.Not.Null);
        }