Exemplo n.º 1
0
        public void Can_get_name()
        {
            var test      = new TestHelper();
            var keyEntity = new xts_keytest {
                Id = Guid.NewGuid()
            };

            keyEntity.Set(e => e.xts_key, "Hello world");
            test.Service.Retrieve(Arg.Is <string>(name => name == "xts_keytest"), Arg.Any <Guid>(), Arg.Any <ColumnSet>())
            .Returns(keyEntity);

            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };

            entity.Set(e => e.xts_referenceid, keyEntity.ToEntityReference());
            var context = Substitute.For <ITransactionContext <xts_entity> >();

            context.Service.Returns(test.Service);
            context.Current.Returns(new TransactionContextEntity <xts_entity>(entity));

            var command = new CommandTest(context);

            Assert.Equal("Hello world", command.GetNameTest <xts_keytest>(e => e.xts_referenceid));
        }
Exemplo n.º 2
0
        public void Change_on_option_set_value_enum(CommandEnumTest?from, CommandEnumTest?to, bool expected)
        {
            var test    = new TestHelper();
            var id      = Guid.NewGuid();
            var initial = new xts_entity {
                Id = id
            };

            initial.Set(e => e.xts_optionsetvalue, CommandEnumTest.Eleven);

            var reference = new xts_entity {
                Id = id
            };

            reference.Set(e => e.xts_optionsetvalue, CommandEnumTest.Thirteen);

            var context = Substitute.For <ITransactionContext <xts_entity> >();

            context.Initial.Returns(initial.ToEntityAccessor());
            context.Current.Returns(new TransactionContextEntity <xts_entity>(reference));

            var command = new CommandTest(context);
            var actual  = command.ChangeTest(e => e.xts_optionsetvalue, from, to);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 3
0
        public void Change_on_entity_reference(EntityReference from, EntityReference to, bool expected)
        {
            var expectedFrom = new EntityReference("entity", new Guid("e6ed2acb-8f66-44c9-847b-5897a2120147"));
            var expectedTo   = new EntityReference("entity", new Guid("c78e077f-81d1-4791-853c-257e47580c86"));
            var test         = new TestHelper();
            var id           = Guid.NewGuid();
            var initial      = new xts_entity {
                Id = id
            };

            initial.Set(e => e.xts_attribute, expectedFrom);

            var reference = new xts_entity {
                Id = id
            };

            reference.Set(e => e.xts_attribute, expectedTo);

            var context = Substitute.For <ITransactionContext <xts_entity> >();

            context.Initial.Returns(initial.ToEntityAccessor());
            context.Current.Returns(new TransactionContextEntity <xts_entity>(reference));

            var command = new CommandTest(context);
            var actual  = command.ChangeTest(e => e.xts_attribute, from, to);

            Assert.Equal(expected, actual);
            actual = command.ChangeTest("xts_attribute", from, to);
            Assert.Equal(expected, actual);
        }
Exemplo n.º 4
0
        public void Can_execute_command_methods()
        {
            var test = new TestHelper();

            var related = new xts_relatedentity {
                Id = Guid.NewGuid()
            };

            related.Set(e => e.xts_name, "RELATED");

            var reference = new xts_entity {
                Id = Guid.NewGuid()
            };

            reference.Set(e => e.xts_optionsetvalue, 12);
            reference.Set(e => e.xts_int, 345);
            reference.Set(e => e.xts_string, "PARENT");
            reference.Set(e => e.xts_referenceid, related.ToEntityReference());
            reference.Set(e => e.xts_money, new Money(1234m));

            reference.SetFormattedValue(e => e.xts_attribute, "Hello Formatted Value");
            reference.SetFormattedValue("xts_anotherattribute", "1234-another-fv");

            var child = new xts_relatedentity {
                Id = Guid.NewGuid()
            };

            child.Set(e => e.xts_name, "CHILD");
            child.Set(e => e.xts_relatedid, reference.ToEntityReference());

            test.Service.Retrieve(Arg.Any <string>(), Arg.Is <Guid>(id => id == related.Id), Arg.Any <ColumnSet>())
            .Returns(related);
            test.Service.Retrieve(Arg.Any <string>(), Arg.Is <Guid>(id => id == child.Id), Arg.Any <ColumnSet>())
            .Returns(child);
            test.Service.RetrieveMultiple(Arg.Any <QueryBase>()).Returns(new EntityCollection(new List <Entity> {
                child
            }));

            var context = Substitute.For <ITransactionContext <xts_entity> >();

            context.Service.Returns(test.Service);
            var txReference = new TransactionContextEntity <xts_entity>(reference);

            context.Current.Returns(txReference);

            var commandTest = new CommandTest(context);

            commandTest.ExecuteTest();

            IEntityWrapperRelation <xts_entity> wrapper = commandTest;

            var relatedColumnSet = new ColumnSet <xts_relatedentity>(
                e => e.Id,
                e => e.xts_name
                );

            var relatedGeneric = wrapper.GetRelated(e => e.xts_referenceid, relatedColumnSet);

            Assert.Equal("RELATED", relatedGeneric.Get(e => e.xts_name));
        }
Exemplo n.º 5
0
        public void Change_on_money_decimal(decimal?from, decimal?to, bool expected)
        {
            var test    = new TestHelper();
            var id      = Guid.NewGuid();
            var initial = new xts_entity {
                Id = id
            };

            initial.Set(e => e.xts_money, 100m);

            var reference = new xts_entity {
                Id = id
            };

            reference.Set(e => e.xts_money, 250m);

            var context = Substitute.For <ITransactionContext <xts_entity> >();

            context.Initial.Returns(initial.ToEntityAccessor());
            context.Current.Returns(new TransactionContextEntity <xts_entity>(reference));

            var command = new CommandTest(context);
            var actual  = command.ChangeTest(e => e.xts_money, from, to);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a fictive test <see cref="ImplementationSelection"/>.
 /// </summary>
 internal static ImplementationSelection CreateTestImplementation1()
 {
     return(new ImplementationSelection
     {
         InterfaceUri = FeedTest.Test1Uri,
         FromFeed = FeedTest.Sub1Uri,
         ID = "id1", ManifestDigest = new ManifestDigest(sha256: "123"), Version = new ImplementationVersion("1.0"),
         Architecture = new Architecture(OS.Windows, Cpu.I586), Languages = { "en-US" },
         DocDir = "doc", Stability = Stability.Developer,
         Bindings =
         {
             new EnvironmentBinding {
                 Name = "TEST1_PATH_SELF", Default = "default", Mode = EnvironmentMode.Append
             },
             new EnvironmentBinding {
                 Name = "TEST1_VALUE", Value = "test1", Mode = EnvironmentMode.Replace
             },
             new EnvironmentBinding {
                 Name = "TEST1_EMPTY", Value = "", Mode = EnvironmentMode.Append
             }
         },
         Dependencies =
         {
             new Dependency
             {
                 InterfaceUri = FeedTest.Test2Uri,
                 Bindings ={ new EnvironmentBinding                {
                   Name = "TEST2_PATH_SUB_DEP", Insert = "sub", Default = "default", Mode = EnvironmentMode.Append
               } }
             }
         },
         Commands = { CommandTest.CreateTestCommand1(), CommandTest.CreateTestCommand1Test() }
     });
 }
Exemplo n.º 7
0
        public void SetUp()
        {
            testCommand = Substitute.For <CommandTest>();
            testBinder  = Substitute.For <IBinder>();

            testSignal          = new TestSignal();
            testSignal.injector = testBinder;
        }
Exemplo n.º 8
0
        public void SetUp()
        {
            testCommand = Substitute.For<CommandTest>();
            testBinder = Substitute.For<IBinder>();

            testSignal = new TestSignal();
            testSignal.injector = testBinder;
        }
Exemplo n.º 9
0
        public void DispatchWithParamsTest()
        {
            testCommand = new CommandTest();
            testSignal.AddCommand(typeof(CommandTest));
            testBinder.Get(typeof(CommandTest)).Returns(testCommand);

            testSignal.Dispatch(PARAM_STRING, PARAM_INT);

            Assert.Fail();
        }
Exemplo n.º 10
0
        public void DispatchWithParamsTest()
        {
            testCommand = new CommandTest();
            testSignal.AddCommand(typeof(CommandTest));
            testBinder.Get(typeof(CommandTest)).Returns(testCommand);

            testSignal.Dispatch(PARAM_STRING, PARAM_INT);

            Assert.Fail();
        }
        public async Task Mediator_AoEnviarComando_RetornarOK()
        {
            // Arrange
            var command = new CommandTest();

            _mocker.GetMock <IMediator>()
            .Setup(x => x.Send(It.IsAny <Command>(), CancellationToken.None))
            .Returns(Task.FromResult(new ResponseResult()));

            // Act
            var responseResult = await _handler.SendCommand(command);

            // Assert
            _mocker.GetMock <IMediator>().Verify(x => x.Send(It.IsAny <Command>(), CancellationToken.None), Times.Once);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Creates a fictive test <see cref="ImplementationSelection"/>.
 /// </summary>
 internal static ImplementationSelection CreateTestImplementation2() => new ImplementationSelection
 {
     InterfaceUri   = FeedTest.Test2Uri,
     FromFeed       = FeedTest.Sub2Uri,
     ID             = "id2",
     ManifestDigest = new ManifestDigest(sha256: "abc"),
     Version        = new ImplementationVersion("1.0"),
     Architecture   = new Architecture(OS.Windows, Cpu.I586),
     Languages      = { "en-US" },
     DocDir         = "doc",
     Stability      = Stability.Developer,
     Bindings       =
     {
         new EnvironmentBinding {
             Name = "TEST2_PATH_SELF", Default = "default", Mode = EnvironmentMode.Prepend
         },
         new EnvironmentBinding {
             Name = "TEST2_VALUE", Value = "test2", Mode = EnvironmentMode.Replace
         }
     },
     Dependencies =
     {
         new Dependency
         {
             InterfaceUri = FeedTest.Test1Uri,
             Bindings     =
             {
                 new ExecutableInVar  {
                     Name = "exec-in-var", Command = Command.NameTest
                 },
                 new ExecutableInPath {
                     Name = "exec-in-path", Command = Command.NameTest
                 }
             }
         }
     },
     Commands = { CommandTest.CreateTestCommand2() }
 };
        public void WhenGatheringAnswersForAnApplication(CommandTest commandTestSetup)
        {
            var signinId  = Guid.NewGuid();
            var contactId = Guid.NewGuid();

            var expectedCommand = new CreateOrganisationContactCommand
            {
                UseTradingName    = commandTestSetup.UseTradingName,
                TradingName       = commandTestSetup.TradingName,
                OrganisationName  = commandTestSetup.OrganisationName,
                IsRoEpaoApproved  = commandTestSetup.IsEpaoApproved,
                OrganisationId    = commandTestSetup.OrganisationId,
                OrganisationType  = commandTestSetup.OrganisationType,
                OrganisationUkprn = commandTestSetup.OrganisationUkprn,
                EndPointAssessorOrganisationId = commandTestSetup.OrganisationReferenceType,

                ContactFamilyName = commandTestSetup.ContactFamilyName,
                ContactGivenNames = commandTestSetup.ContactGivenNames,

                ContactAddress1 = commandTestSetup.ContactAddress != null
                    ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "AddressLine1")
                    : commandTestSetup.ContactAddress1,

                ContactAddress2 = commandTestSetup.ContactAddress != null
                    ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "AddressLine2")
                    : commandTestSetup.ContactAddress2,

                ContactAddress3 = commandTestSetup.ContactAddress != null
                    ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "AddressLine3")
                    : commandTestSetup.ContactAddress3,

                ContactAddress4 = commandTestSetup.ContactAddress != null
                    ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "AddressLine4")
                    : commandTestSetup.ContactAddress4,

                ContactPostcode = commandTestSetup.ContactAddress != null
                    ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "Postcode")
                    : commandTestSetup.ContactPostcode,

                ContactEmail              = commandTestSetup.ContactEmail,
                ContactPhoneNumber        = commandTestSetup.ContactPhoneNumber,
                CompanyUkprn              = commandTestSetup.CompanyUkprn,
                CompanyNumber             = commandTestSetup.CompanyNumber,
                CharityNumber             = commandTestSetup.CharityNumber,
                StandardWebsite           = commandTestSetup.StandardWebsite,
                ApplyingContactEmail      = "",
                ApplyingContactGivenNames = "",
                ApplyingContactFamilyName = "",
                ApplyingContactId         = contactId,
                FinancialDueDate          = commandTestSetup.FinancialDueDate,
                IsFinancialExempt         = commandTestSetup.IsFinancialExempt,
                OtherApplyingUserEmails   = new List <string>()
            };

            var applicationData = new Dictionary <string, object>
            {
                ["trading_name"]         = commandTestSetup.TradingName,
                ["use_trading_name"]     = commandTestSetup.UseTradingName,
                ["contact_given_name"]   = commandTestSetup.ContactGivenNames,
                ["contact_family_name"]  = commandTestSetup.ContactFamilyName,
                ["contact_address"]      = commandTestSetup.ContactAddress,
                ["contact_address1"]     = commandTestSetup.ContactAddress1,
                ["contact_address2"]     = commandTestSetup.ContactAddress2,
                ["contact_address3"]     = commandTestSetup.ContactAddress3,
                ["contact_address4"]     = commandTestSetup.ContactAddress4,
                ["contact_postcode"]     = commandTestSetup.ContactPostcode,
                ["contact_email"]        = commandTestSetup.ContactEmail,
                ["contact_phone_number"] = commandTestSetup.ContactPhoneNumber,
                ["company_ukprn"]        = commandTestSetup.CompanyUkprn,
                ["company_number"]       = commandTestSetup.CompanyNumber,
                ["charity_number"]       = commandTestSetup.CharityNumber,
                ["standard_website"]     = commandTestSetup.StandardWebsite
            };

            var applicationOrganisation = new Organisation
            {
                Id = commandTestSetup.OrganisationId,
                EndPointAssessorName = commandTestSetup.OrganisationName,
                OrganisationType     = new AssessorService.Domain.Entities.OrganisationType {
                    Type = commandTestSetup.OrganisationType
                },
                EndPointAssessorUkprn          = commandTestSetup.OrganisationUkprn,
                EndPointAssessorOrganisationId = commandTestSetup.OrganisationReferenceType,
                OrganisationData = new AssessorService.Domain.Entities.OrganisationData
                {
                    RoEPAOApproved = commandTestSetup.IsEpaoApproved != null && commandTestSetup.IsEpaoApproved.Value,
                    FHADetails     = new FHADetails
                    {
                        FinancialDueDate = commandTestSetup.FinancialDueDate,
                        FinancialExempt  = commandTestSetup.IsFinancialExempt
                    }
                }
            };

            var applicationContact = new Contact {
                Id = contactId, SignInId = signinId, FamilyName = "", GivenNames = "", Email = ""
            };

            var application = new ApplicationResponse
            {
                Id             = _applicationId,
                ApplicationId  = _applicationId,
                OrganisationId = applicationOrganisation.Id,
                CreatedBy      = applicationContact.Id.ToString()
            };

            _mockApplicationApiClient.Setup(x => x.GetApplication(application.Id)).ReturnsAsync(application);
            _mockQnaApiClient.Setup(x => x.GetApplicationDataDictionary(application.ApplicationId)).ReturnsAsync(applicationData);
            _mockApiClient.Setup(x => x.GetOrganisation(application.OrganisationId)).ReturnsAsync(applicationOrganisation);
            _mockApiClient.Setup(x => x.GetOrganisationContacts(applicationOrganisation.Id)).ReturnsAsync(new List <Contact> {
                applicationContact
            });

            var actualCommand = _answerService.GatherAnswersForOrganisationAndContactForApplication(_applicationId).Result;

            Assert.AreEqual(JsonConvert.SerializeObject(expectedCommand), JsonConvert.SerializeObject(actualCommand));
        }
Exemplo n.º 14
0
 public void TearDown()
 {
     testSignal = null;
     testBinder = null;
     testCommand = null;
 }
Exemplo n.º 15
0
        public static void Main(string[] args)
        {
            int option    = 1;
            int i_option  = 1;
            int ii_option = 1;

            // YO AMO A MI ESPOSA :) LE VOY A COMPRAR MUCHOS REGALOS :)

            while (option != 0)
            {
                ConsoleUtility.WriteLine("Choose an option based in the next menu");
                ConsoleUtility.WriteLine("1.-Algorithm");
                ConsoleUtility.WriteLine("2.-DataStructures");
                ConsoleUtility.WriteLine("3.-Design Patterns");
                ConsoleUtility.WriteLine("4.-Language DotNet");
                option = Convert.ToInt32(Console.ReadLine());
                switch (option)
                {
                case 1:
                    ConsoleUtility.WriteLine("Algorithm");
                    ConsoleUtility.WriteLine("1.-Linear Table");
                    ConsoleUtility.WriteLine("2.-Linear Table Append");
                    ConsoleUtility.WriteLine("3.-Linear Table Delete");
                    ConsoleUtility.WriteLine("4.-Linear Table Insert");
                    ConsoleUtility.WriteLine("5.-Linear Table Search");
                    ConsoleUtility.WriteLine("6.-Factorial");
                    ConsoleUtility.WriteLine("7.-Bubble Sort");
                    ConsoleUtility.WriteLine("8.-Heap Sort");
                    ConsoleUtility.WriteLine("9.-Insert Sorting");
                    ConsoleUtility.WriteLine("10.-Merge Sort");
                    ConsoleUtility.WriteLine("11.-Quick Sort");
                    ConsoleUtility.WriteLine("12.-Select Sort");
                    ConsoleUtility.WriteLine("13.-Binary Search");
                    ConsoleUtility.WriteLine("14.-Fibonnacci");
                    ConsoleUtility.WriteLine("15.-Fibonacci with Memoization");
                    i_option = Convert.ToInt32(Console.ReadLine());
                    switch (i_option)
                    {
                    case 1:
                        ConsoleUtility.WriteLine("Running example of Linear Table");
                        LinearTable linearTable = new LinearTable();
                        linearTable.Run();
                        break;

                    case 2:
                        ConsoleUtility.WriteLine("Running example of Linear Table Append");
                        LinearTableAppend linearTableAppend = new LinearTableAppend();
                        linearTableAppend.Run();
                        break;

                    case 3:
                        ConsoleUtility.WriteLine("Running example of Linear Table Delete");
                        LinearTableDelete linearTableDelete = new LinearTableDelete();
                        linearTableDelete.Run();
                        break;

                    case 4:
                        ConsoleUtility.WriteLine("Running example of Linear Table Insert");
                        LinearTableInsert linearTableInsert = new LinearTableInsert();
                        linearTableInsert.Run();
                        break;

                    case 5:
                        ConsoleUtility.WriteLine("Running example of Linear Table Search");
                        LinearTableSearch linearTableSearch = new LinearTableSearch();
                        linearTableSearch.Run();
                        break;

                    case 6:
                        ConsoleUtility.WriteLine("Running example of Factorial");
                        Factorial factorial = new Factorial();
                        factorial.Run();
                        break;

                    case 7:
                        ConsoleUtility.WriteLine("Running example of Bubble Sort");
                        BubbleSort bubbleSort = new BubbleSort();
                        bubbleSort.Run();
                        break;

                    case 8:
                        ConsoleUtility.WriteLine("Running example of HeapSort");
                        HeapSort heapSort = new HeapSort();
                        heapSort.Run();
                        break;

                    case 9:
                        ConsoleUtility.WriteLine("Running example of InsertSorting");
                        InsertSorting insertSorting = new InsertSorting();
                        insertSorting.Run();
                        break;

                    case 10:
                        ConsoleUtility.WriteLine("Running example of Merge Sort");
                        MergeSort mergeSort = new MergeSort();
                        mergeSort.Run();
                        break;

                    case 11:
                        ConsoleUtility.WriteLine("Running example pf Quick Sort");
                        QuickSort quickSort = new QuickSort();
                        quickSort.Run();
                        break;

                    case 12:
                        ConsoleUtility.WriteLine("Running example of Select Sort");
                        SelectSort selectSort = new SelectSort();
                        selectSort.Run();
                        break;

                    case 13:
                        ConsoleUtility.WriteLine("Running example of Binary Search");
                        BinarySearch binarySearch = new BinarySearch();
                        binarySearch.Run();
                        break;

                    case 14:
                        ConsoleUtility.WriteLine("Running example of Fibonnacci");
                        Fibonnacci fibonnacci = new Fibonnacci();
                        fibonnacci.Run();
                        break;

                    case 15:
                        ConsoleUtility.WriteLine("Running example of Fibonnaci with Memoization");
                        FibonacciMemoization fibonacciMemoization = new FibonacciMemoization();
                        fibonacciMemoization.Run();
                        break;

                    default:
                        break;
                    }
                    break;

                case 2:
                    ConsoleUtility.WriteLine("Data Structures");
                    ConsoleUtility.WriteLine("1.-Binary Search Tree");
                    ConsoleUtility.WriteLine("2.-Binary Tree");
                    ConsoleUtility.WriteLine("3.-Doubly Linked List");
                    ConsoleUtility.WriteLine("4.-Double Linked List");
                    ConsoleUtility.WriteLine("5.-Hash Table");
                    ConsoleUtility.WriteLine("6.-Linked List");
                    ConsoleUtility.WriteLine("7.-One Way Circular List");
                    ConsoleUtility.WriteLine("8.-Queue");
                    ConsoleUtility.WriteLine("9.-Stack");
                    ConsoleUtility.WriteLine("10.-Two Way Circular List");
                    ConsoleUtility.WriteLine("11.-Unidirectional Linked List");
                    i_option = Convert.ToInt32(Console.ReadLine());
                    ConsoleUtility.WriteLine($"you choose option {i_option}");
                    switch (i_option)
                    {
                    case 1:
                        ConsoleUtility.WriteLine("Running example of Binary Search Tree");
                        BinarySearchTree binarySearchTree = new BinarySearchTree();
                        binarySearchTree.Run();
                        break;

                    case 2:
                        ConsoleUtility.WriteLine("Running example of Binary Tree");
                        BinaryTree binaryTree = new BinaryTree();
                        binaryTree.Run();
                        break;

                    case 3:
                        ConsoleUtility.WriteLine("Running example of DoublyLinkedList");
                        DoublyLinkedList doublyLinkedList = new DoublyLinkedList();
                        doublyLinkedList.Run();
                        break;

                    case 4:
                        ConsoleUtility.WriteLine("Running example of DoubleLinkedList");
                        DoubleLinkedList doubleLinkedList = new DoubleLinkedList();
                        doubleLinkedList.Run();
                        break;

                    case 5:
                        ConsoleUtility.WriteLine("Running example of HashTable");
                        HashTable hashTable = new HashTable();
                        hashTable.Run();
                        break;

                    case 6:
                        ConsoleUtility.WriteLine("Running example of Linked List");
                        LinkedList <int> linkedList = new LinkedList <int>();
                        linkedList.Run();
                        break;

                    case 7:
                        ConsoleUtility.WriteLine("Running example of One Way Circular List");
                        OneWayCircularList circularList = new OneWayCircularList();
                        circularList.Run();
                        break;

                    case 8:
                        ConsoleUtility.WriteLine("Running example of Queue");
                        Queue queue = new Queue();
                        queue.Run();
                        break;

                    case 9:
                        ConsoleUtility.WriteLine("Running example of Stack");
                        Stack stack = new Stack();
                        stack.Run();
                        break;

                    case 10:
                        ConsoleUtility.WriteLine("Running example of Two Way Circular List");
                        TwoWayCircularList twoWay = new TwoWayCircularList();
                        twoWay.Run();
                        break;

                    case 11:
                        ConsoleUtility.WriteLine("Running example fo Unidirectional Linked List");
                        UnidirectionalLinkedList unidirectionalLinkedList = new UnidirectionalLinkedList();
                        unidirectionalLinkedList.Run();
                        break;

                    default:
                        break;
                    }
                    break;

                case 3:
                    ConsoleUtility.WriteLine("Design Patterns");
                    ConsoleUtility.WriteLine("1.-Creational");
                    ConsoleUtility.WriteLine("2.-Structural");
                    ConsoleUtility.WriteLine("3.-Behavioral");
                    ConsoleUtility.WriteLine("4.-SOLID Principles");

                    i_option = Convert.ToInt32(Console.ReadLine());
                    ConsoleUtility.WriteLine($"you choose option {i_option}");
                    switch (i_option)
                    {
                    case 1:
                        ConsoleUtility.WriteLine("Example of creational design patterns");
                        ConsoleUtility.WriteLine("1.-Singleton");
                        ConsoleUtility.WriteLine("2.-Factory");
                        ConsoleUtility.WriteLine("3.-Builder");
                        ConsoleUtility.WriteLine("4.-Prototype");
                        ConsoleUtility.WriteLine("5.-Fluent Interface");
                        ConsoleUtility.WriteLine("6.-Factory Method");
                        ConsoleUtility.WriteLine("7.-Abstract Factory");
                        ConsoleUtility.WriteLine("Select one option");
                        ii_option = Convert.ToInt32(Console.ReadLine());
                        switch (ii_option)
                        {
                        case 1:
                            ConsoleUtility.WriteLine("Running example of singleton design pattern");
                            SingletonTest singletonTest = new SingletonTest();
                            singletonTest.Run();
                            break;

                        case 2:
                            ConsoleUtility.WriteLine("Runnig example of Factory design pattern");
                            FactoryTest factoryTest = new FactoryTest();
                            factoryTest.Run();
                            break;

                        case 3:
                            ConsoleUtility.WriteLine("Running example fo Builder Desiogn Pattern");
                            BuilderTest builderTest = new BuilderTest();
                            builderTest.Run();
                            break;

                        case 4:
                            ConsoleUtility.WriteLine("Running example of Prototype Design Pattern");
                            PrototypeTest prototype = new PrototypeTest();
                            prototype.Run();
                            break;

                        case 5:
                            ConsoleUtility.WriteLine("Running example of Fluent Interface Design Patter");
                            FluentInterface fluent = new FluentInterface();
                            fluent.Run();
                            break;

                        case 6:
                            ConsoleUtility.WriteLine("Running example of Factory Method Design Pattern");
                            FactoryMethodTest factory = new FactoryMethodTest();
                            factory.Run();
                            break;

                        case 7:
                            ConsoleUtility.WriteLine("Running example of Abstract Factory");
                            AbstractFactoryTest abstractFactory = new AbstractFactoryTest();
                            abstractFactory.Run();
                            break;

                        default:
                            break;
                        }
                        break;

                    case 2:
                        ConsoleUtility.WriteLine("Example of Structural Design Pattern");
                        ConsoleUtility.WriteLine("1.-Adapter");
                        ConsoleUtility.WriteLine("2.-Facade");
                        ConsoleUtility.WriteLine("3.-Decorator");
                        ConsoleUtility.WriteLine("4.-Composite");
                        ConsoleUtility.WriteLine("5.-Proxy");
                        ConsoleUtility.WriteLine("6.-Flyweight");
                        ConsoleUtility.WriteLine("7.-Bridge");
                        ii_option = Convert.ToInt32(Console.ReadLine());
                        switch (ii_option)
                        {
                        case 1:
                            ConsoleUtility.WriteLine("Running example of Adapter");
                            AdapterTest adapter = new AdapterTest();
                            adapter.Run();
                            break;

                        case 2:
                            ConsoleUtility.WriteLine("Running example of Facade");
                            FacadeTest facade = new FacadeTest();
                            facade.Run();
                            break;

                        case 3:
                            ConsoleUtility.WriteLine("Running example of Decorator");
                            DecoratorTest decorator = new DecoratorTest();
                            decorator.Run();
                            break;

                        case 4:
                            ConsoleUtility.WriteLine("Running example of Composite");
                            CompositeTest composite = new CompositeTest();
                            composite.Run();
                            break;

                        case 5:
                            ConsoleUtility.WriteLine("Running example of Proxy");
                            ProxyTest proxy = new ProxyTest();
                            proxy.Run();
                            break;

                        case 6:
                            ConsoleUtility.WriteLine("Running example of Flyweight");
                            FlyweightTest flyweight = new FlyweightTest();
                            flyweight.Run();
                            break;

                        case 7:
                            ConsoleUtility.WriteLine("Running example of Bridge");
                            BridgeTest bridge = new BridgeTest();
                            bridge.Run();
                            break;

                        default:
                            break;
                        }
                        break;

                    case 3:
                        ConsoleUtility.WriteLine("Example of Behavioral Design Pattern");
                        ConsoleUtility.WriteLine("1.-Chain of Responsability");
                        ConsoleUtility.WriteLine("2.-Command");
                        ConsoleUtility.WriteLine("3.-Observer");
                        ConsoleUtility.WriteLine("4.-Iterator");
                        ConsoleUtility.WriteLine("5.-State");
                        ConsoleUtility.WriteLine("6.-Template Method");
                        ConsoleUtility.WriteLine("7.-Visitor");
                        ConsoleUtility.WriteLine("8.-Strategy");
                        ConsoleUtility.WriteLine("9.-Mediator");
                        ConsoleUtility.WriteLine("10.-Memento");
                        ConsoleUtility.WriteLine("11.-Interpreter");
                        ii_option = Convert.ToInt32(Console.ReadLine());
                        switch (ii_option)
                        {
                        case 1:
                            ConsoleUtility.WriteLine("Running example of Change Of Responsability");
                            ChainOfResponsability chain = new ChainOfResponsability();
                            chain.Run();
                            break;

                        case 2:
                            ConsoleUtility.WriteLine("Running example of Command");
                            CommandTest command = new CommandTest();
                            command.Run();
                            break;

                        case 3:
                            ConsoleUtility.WriteLine("Running example of Observer");
                            ObserverTest observer = new ObserverTest();
                            observer.Run();
                            break;

                        case 4:
                            ConsoleUtility.WriteLine("Running example of Iterator");
                            IteratorTest iterator = new IteratorTest();
                            iterator.Run();
                            break;

                        case 5:
                            ConsoleUtility.WriteLine("Running example of State");
                            StateTest state = new StateTest();
                            state.Run();
                            break;

                        case 6:
                            ConsoleUtility.WriteLine("Running example of Template Method");
                            TemplateMehodTest templateMehod = new TemplateMehodTest();
                            templateMehod.Run();
                            break;

                        case 7:
                            ConsoleUtility.WriteLine("Running example of Visitor");
                            VisitorTest visitor = new VisitorTest();
                            visitor.Run();
                            break;

                        case 8:
                            ConsoleUtility.WriteLine("Running example of stratgegy");
                            StrategyTest strategy = new StrategyTest();
                            strategy.Run();
                            break;

                        case 9:
                            ConsoleUtility.WriteLine("Running example of Mediator");
                            MediatorTest mediator = new MediatorTest();
                            mediator.Run();
                            break;

                        case 10:
                            ConsoleUtility.WriteLine("Running example of Memento");
                            MementoTest memento = new MementoTest();
                            memento.Run();
                            break;

                        case 11:
                            ConsoleUtility.WriteLine("Running example of Interpreter");
                            InterpreterTest interpreter = new InterpreterTest();
                            interpreter.Run();
                            break;

                        default:
                            break;
                        }
                        break;

                    case 4:
                        ConsoleUtility.WriteLine("Example of SOLID Principles");
                        ConsoleUtility.WriteLine("1.-Single Responsibility Principle");
                        ConsoleUtility.WriteLine("2.-Open-Closed Principle");
                        ConsoleUtility.WriteLine("3.-Liskov Substitution Principle");
                        ConsoleUtility.WriteLine("4.-Interface Segregation Principle");
                        ConsoleUtility.WriteLine("5.-Dependency Inversion Principle");
                        ii_option = Convert.ToInt32(Console.ReadLine());
                        switch (ii_option)
                        {
                        case 1:
                            ConsoleUtility.WriteLine("Running example of Single Responsibility");
                            Invoice invoice = new Invoice();
                            invoice.Run();
                            break;

                        case 2:
                            ConsoleUtility.WriteLine("Running example of Open-Closed Principle");
                            InvoiceOCP invoiceOCP = new InvoiceOCP();
                            invoiceOCP.Run();
                            break;

                        case 3:
                            ConsoleUtility.WriteLine("Running example of Liskov Principle");
                            RunFruit run = new RunFruit();
                            run.Run();
                            break;

                        case 4:
                            ConsoleUtility.WriteLine("Running example of Interface Segregation Principle");
                            Printer printer = new Printer();
                            printer.Run();
                            break;

                        case 5:
                            ConsoleUtility.WriteLine("Running example of Dependency Inversion Principle");
                            RunDIP runDIP = new RunDIP();
                            runDIP.Run();
                            break;
                        }
                        break;

                    default:
                        break;
                    }
                    break;

                case 4:
                    ConsoleUtility.WriteLine("Language DotNet");
                    ConsoleUtility.WriteLine("1.-Abstract");
                    ConsoleUtility.WriteLine("2.-Action");
                    ConsoleUtility.WriteLine("3.-AsyncAwait");
                    ConsoleUtility.WriteLine("4.-Delegate");
                    ConsoleUtility.WriteLine("5.-Extensions");
                    ConsoleUtility.WriteLine("6.-Func");
                    ConsoleUtility.WriteLine("7.-Generics");
                    ConsoleUtility.WriteLine("8.-Predicate");
                    ConsoleUtility.WriteLine("9.-Lock");
                    ConsoleUtility.WriteLine("10.-Reflection");
                    ConsoleUtility.WriteLine("11.-IOC Implementation");
                    ConsoleUtility.WriteLine("12.-Task");
                    ConsoleUtility.WriteLine("13.-Out Variable");
                    ConsoleUtility.WriteLine("14.-Pattern Matching");
                    ConsoleUtility.WriteLine("15.-Digit Separator");
                    ConsoleUtility.WriteLine("16.-Tuples");
                    ConsoleUtility.WriteLine("17.-Ref locals and ref return");
                    ConsoleUtility.WriteLine("18.-AsynReturn");
                    i_option = Convert.ToInt32(Console.ReadLine());
                    switch (i_option)
                    {
                    case 1:
                        ConsoleUtility.WriteLine("Running example of Abstract Class");
                        Square square = new Square();
                        square.Run();
                        break;

                    case 2:
                        ConsoleUtility.WriteLine("Running example of Action");
                        LanguageDotNet.Action action = new LanguageDotNet.Action();
                        action.Run();
                        break;

                    case 3:
                        ConsoleUtility.WriteLine("Running example of AsyncAwait");
                        AsyncAwait asyncAwait = new AsyncAwait();
                        asyncAwait.Run();
                        break;

                    case 4:
                        ConsoleUtility.WriteLine("Running example of Delegate");
                        Number number = new Number();
                        number.Run();
                        break;

                    case 5:
                        ConsoleUtility.WriteLine("Running example of Extensions");
                        IntExtensions intExtensions = new IntExtensions();
                        intExtensions.Run();
                        break;

                    case 6:
                        ConsoleUtility.WriteLine("Running example of Func");
                        Func func = new Func();
                        func.Run();
                        break;

                    case 7:
                        ConsoleUtility.WriteLine("Running example of Generics");
                        Generic generic = new Generic();
                        generic.Run();
                        break;

                    case 8:
                        ConsoleUtility.WriteLine("Running example of Predicate");
                        Predicate predicate = new Predicate();
                        predicate.Run();
                        break;

                    case 9:
                        ConsoleUtility.WriteLine("Running example of Lock");
                        LockTest lockTest = new LockTest();
                        lockTest.runTest();
                        break;

                    case 10:
                        ConsoleUtility.WriteLine("Running example of Reflection");
                        Customer customer = new Customer();
                        customer.Run();
                        break;

                    case 11:
                        ConsoleUtility.WriteLine("Running example of IOC Implementation");
                        IOCImplementation.Run();
                        break;

                    case 12:
                        ConsoleUtility.WriteLine("Running example of Tasks");
                        TaskReturnValue taskReturnValue = new TaskReturnValue();
                        taskReturnValue.Run();
                        break;

                    case 13:
                        ConsoleUtility.WriteLine("Running example of Out variable");
                        OutVariables outVariables = new OutVariables();
                        outVariables.Run();
                        break;

                    case 14:
                        ConsoleUtility.WriteLine("Running example of Pattern Matching");
                        PatternMatching patternMatching = new PatternMatching();
                        patternMatching.Run();
                        break;

                    case 15:
                        ConsoleUtility.WriteLine("Running example of Digit Separators");
                        DigitSeparator digitSeparator = new DigitSeparator();
                        digitSeparator.Run();
                        break;

                    case 16:
                        ConsoleUtility.WriteLine("Running example of Tuple");
                        Tuples tuples = new Tuples();
                        tuples.Run();
                        break;

                    case 17:
                        ConsoleUtility.WriteLine("Running example of Ref locals and ref returns");
                        RefLocalRefReturn refLocalRefReturn = new RefLocalRefReturn();
                        refLocalRefReturn.Run();
                        break;

                    case 18:
                        ConsoleUtility.WriteLine("Running example of AsyncReturn");
                        AsyncReturn asyncReturn = new AsyncReturn();
                        asyncReturn.Run();
                        break;

                    default:
                        break;
                    }
                    break;

                default:
                    ConsoleUtility.WriteLine("Exit");
                    break;
                }
            }
        }
Exemplo n.º 16
0
 public void TearDown()
 {
     testSignal  = null;
     testBinder  = null;
     testCommand = null;
 }
Exemplo n.º 17
0
        private void InitButtons()
        {
            // Possibilite d'implanter une factory de panels pour simplifier le code ici
            StackPanel panelButtonFinTour = new StackPanel();

            panelButtonFinTour.Name = "panelBtnFinTour";
            PlateauMonopoly.Children.Add(panelButtonFinTour);
            Grid.SetRow(panelButtonFinTour, 10);
            Grid.SetColumn(panelButtonFinTour, 6);
            Grid.SetColumnSpan(panelButtonFinTour, 2);

            // Possibilite d'implanter une factory de buttons pour simplifier le code ici
            ButtonMonopoly   buttonLancerDes = new ButtonMonopoly();
            CommandLancerDes cmdLancerDes    = commandFactory.CreateCommandLancerDes();

            buttonLancerDes.storeCommand(cmdLancerDes);
            buttonLancerDes.Name    = "btnLancerDes";
            buttonLancerDes.Content = "Lancer les dés";
            buttonLancerDes.Click  += buttonLancerDes.execute;
            panelButtonFinTour.Children.Add(buttonLancerDes);


            ButtonMonopoly buttonFinTour = new ButtonMonopoly();
            CommandFinTour cmdFinTour    = commandFactory.CreateCommandFinTour();

            // Possibilite d'implanter une factory de buttons pour simplifier le code ici
            ButtonMonopoly            buttonEchangerProprietes = new ButtonMonopoly();
            CommandEchangerProprietes cmdEchangerProprietes    = commandFactory.CreateCommandEchangerProprietes();

            buttonEchangerProprietes.storeCommand(cmdEchangerProprietes);
            buttonEchangerProprietes.Name    = "btnEchangerProprietes";
            buttonEchangerProprietes.Content = "Échanger les propriétés";
            buttonEchangerProprietes.Click  += buttonEchangerProprietes.execute;
            panelButtonFinTour.Children.Add(buttonEchangerProprietes);

            //  SubMenu item sauve
            MenuItemMonopoly  menuSauvegarde = new MenuItemMonopoly();
            CommandSauvegarde cmdSauver      = CommandFactory.Instance.CreateCommandSauvegarde();

            menuSauvegarde.storeCommand(cmdSauver);
            menuSauvegarde.Name   = "menuSave";
            menuSauvegarde.Header = "Sauvegarde";
            menuSauvegarde.Click += menuSauvegarde.execute;
            menuItemFichier.Items.Add(menuSauvegarde);

            //  sub Menu item restaure
            MenuItemMonopoly menuRestaure = new MenuItemMonopoly();
            CommandRestaurer cmdRestaurer = CommandFactory.Instance.CreateCommandRestaurer();

            menuRestaure.storeCommand(cmdRestaurer);
            menuRestaure.Name   = "menuRestaure";
            menuRestaure.Header = "Restaurer";
            menuRestaure.Click += menuRestaure.execute;
            menuItemFichier.Items.Add(menuRestaure);

            //  sub menu item test
            MenuItemMonopoly menuTest = new MenuItemMonopoly();
            CommandTest      cmdTest  = CommandFactory.Instance.CreateCommandTest();

            menuTest.storeCommand(cmdTest);
            menuTest.Name   = "menuTest";
            menuTest.Header = "Panneau Test";
            menuTest.Click += menuTest.execute;
            menuItemTest.Items.Add(menuTest);
        }
Exemplo n.º 18
0
    public override void OnInspectorGUI()
    {
        CommandTest commandTest = (CommandTest)target;

        EditorGUILayout.TextArea(commandTest.commandsQueue);
    }