Example #1
0
        public void StopClerksNoClerksTest()
        {
            var fDesk = new FrontDesk();
            var res   = fDesk.StopClerks();

            Assert.AreEqual(res.Code, ResultCode.NoPluginsLoaded);
        }
        /// <summary>
        /// Client
        /// </summary>
        /// <remarks>
        /// Initiates the request to a ConcreteHandler object on the chain.
        /// </remarks>
        public override void Execute()
        {
            // Create the customer support team
            CustomerSupport frontDesk = new FrontDesk();
            CustomerSupport lead      = new Lead();
            CustomerSupport engineer  = new Engineer();
            CustomerSupport manager   = new Manager();

            // Define the hierarchy: [FrontDesk] -> [Lead] -> [Engineer] -> [Manager]
            frontDesk.SetEscalation(lead);
            lead.SetEscalation(engineer);
            engineer.SetEscalation(manager);


            var simpleProblem = new Problem(ProblemSeverity.Simple);

            frontDesk.SolveProblem(simpleProblem);
            // The problem should be directly resolved by the FrontDesk
            Assert.True(simpleProblem.Solved);
            Assert.Equal(frontDesk, simpleProblem.SolvedBy);


            var criticalProblem = new Problem(ProblemSeverity.Critical);

            frontDesk.SolveProblem(criticalProblem);
            // The problem should go through [FrontDesk] -> [Lead] -> [Engineer]
            Assert.True(criticalProblem.Solved);
            Assert.NotEqual(frontDesk, criticalProblem.SolvedBy);
            Assert.NotEqual(lead, criticalProblem.SolvedBy);
            Assert.Equal(engineer, criticalProblem.SolvedBy);
        }
Example #3
0
        static void Main(string[] args)
        {
            IFrontDesk frontDesk            = new FrontDesk();
            var        commissionCalculator = new CommissionCalculator();

            Console.WriteLine("Select asset type: \n" +
                              "1. House; \n" +
                              "2. Apartment; \n" +
                              "3. Single Room; \n" +
                              "4. Urban Plot. \n");

            var assetType = Console.ReadLine();

            IAsset asset;

            switch (assetType)
            {
            case "1":
                asset = new House();
                Console.WriteLine("Insert the address of the House: ");
                asset.SetAssetAttribute(Console.ReadLine());
                Console.WriteLine("\nInsert the desired price: ");
                asset.Price = Convert.ToDecimal(Console.ReadLine());
                frontDesk.CalculateSellingPrice(asset, commissionCalculator);
                break;

            case "2":
                asset = new Apartment();
                Console.WriteLine("Insert the address of the Apartment: ");
                asset.SetAssetAttribute(Console.ReadLine());
                Console.WriteLine("\nInsert the desired price: ");
                asset.Price = Convert.ToDecimal(Console.ReadLine());
                frontDesk.CalculateSellingPrice(asset, commissionCalculator);
                break;

            case "3":
                asset = new SingleRoom();
                Console.WriteLine("Insert the address of the Single Room: ");
                asset.SetAssetAttribute(Console.ReadLine());
                Console.WriteLine("\nInsert the desired price: ");
                asset.Price = Convert.ToDecimal(Console.ReadLine());
                frontDesk.CalculateSellingPrice(asset, commissionCalculator);
                break;

            case "4":
                asset = new UrbanPlot();
                Console.WriteLine("Insert the Cadastral Reference of the Urban Plot: ");
                asset.SetAssetAttribute(Console.ReadLine());
                Console.WriteLine("\nInsert the desired price: ");
                asset.Price = Convert.ToDecimal(Console.ReadLine());
                frontDesk.CalculateSellingPrice(asset, commissionCalculator);
                break;

            default:
                break;
            }
        }
        public void BeforeEachTest()
        {
            _queueField = typeof(Chef).GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
                          .FirstOrDefault(f => f.FieldType.IsAssignableFrom(typeof(Queue <IOrder>)));

            _frontDesk       = new FrontDesk();
            _chefActionsMock = new Mock <IChefActions>();
            _chef            = new Chef(_frontDesk, _chefActionsMock.Object);
        }
Example #5
0
        public void GetClerkBadTest()
        {
            var fDesk = new FrontDesk(assemblies: new List <Assembly>()
            {
                typeof(SampleClerk).Assembly
            });
            var value = fDesk.GetClerk("invalid");

            Assert.IsNull(value);
        }
Example #6
0
        public void FrontDeskTest()
        {
            var           fDesk   = new FrontDesk();
            PrivateObject pObj    = new PrivateObject(fDesk);
            var           plugins = pObj.GetField("_Handler") as PluginHandler <IClerk, IPluginData>;
            PrivateObject pObj2   = new PrivateObject(plugins);
            var           paths   = pObj2.GetField("_Paths") as List <String>;

            Assert.AreEqual(paths.Count, 0);
        }
Example #7
0
        public void StopClerksTest()
        {
            var fDesk = new FrontDesk(assemblies: new List <Assembly>()
            {
                typeof(SampleClerk).Assembly
            });
            var res = fDesk.StopClerks();

            Assert.AreEqual(res.Code, ResultCode.Success);
        }
Example #8
0
        public void GetClerkTest()
        {
            var fDesk = new FrontDesk(assemblies: new List <Assembly>()
            {
                typeof(SampleClerk).Assembly
            });
            var value = fDesk.GetClerk("SampleClerk");

            Assert.IsNotNull(value);
            Assert.AreEqual("SampleClerk", value.ID);
        }
Example #9
0
        public MainWindow()
        {
            InitializeComponent();

            FrontDesk = new FrontDesk();
            _chef     = new Chef(FrontDesk, new DummyChefActions(2, 1));

            _cancellationTokenSource = new CancellationTokenSource();
            _chef.StartProcessingOrders(_cancellationTokenSource.Token);

            DataContext = FrontDesk;
        }
Example #10
0
        public void FrontDeskArgsTest()
        {
            var lTest = new List <string>()
            {
                "test", "test2", "test3"
            };
            var           fDesk   = new FrontDesk(lTest);
            PrivateObject pObj    = new PrivateObject(fDesk);
            var           plugins = pObj.GetField("_Handler") as PluginHandler <IClerk, IPluginData>;
            PrivateObject pObj2   = new PrivateObject(plugins);
            var           paths   = pObj2.GetField("_Paths") as List <String>;

            Assert.IsTrue(lTest.SequenceEqual(paths));
        }
Example #11
0
        public void register_markerzones()
        {
            //Create locker.
            Locker.Create();

            if (Locker != MarkerZone.None)
            {
                Locker.ColZone.OnEntityEnterColShape += (shape, entity) =>
                {
                    if (API.Shared.GetEntityType(entity) != EntityType.Player)
                    {
                        return;
                    }
                    foreach (var c in PlayerManager.Players)
                    {
                        if (c.Client != entity)
                        {
                            continue;
                        }
                        c.LockerZoneGroup = this;
                    }
                };
                Locker.ColZone.OnEntityEnterColShape += (shape, entity) =>
                {
                    if (API.Shared.GetEntityType(entity) != EntityType.Player)
                    {
                        return;
                    }
                    foreach (var c in PlayerManager.Players)
                    {
                        if (c.Client != entity)
                        {
                            continue;
                        }
                        c.LockerZoneGroup = Group.None;
                    }
                };
            }

            FrontDesk.Create();

            if (FrontDesk != MarkerZone.None)
            {
                FrontDesk.ColZone.OnEntityEnterColShape += (shape, entity) =>
                {
                    if (API.Shared.GetEntityType(entity) != EntityType.Player)
                    {
                        return;
                    }
                    foreach (var c in PlayerManager.Players)
                    {
                        if (c.Client != entity)
                        {
                            continue;
                        }
                    }
                };
                FrontDesk.ColZone.OnEntityEnterColShape += (shape, entity) =>
                {
                    if (API.Shared.GetEntityType(entity) != EntityType.Player)
                    {
                        return;
                    }
                    foreach (var c in PlayerManager.Players)
                    {
                        if (c.Client != entity)
                        {
                            continue;
                        }
                    }
                };
            }

            ArrestLocation.Create();

            if (ArrestLocation != MarkerZone.None)
            {
                ArrestLocation.ColZone.OnEntityEnterColShape += (shape, entity) =>
                {
                    if (API.Shared.GetEntityType(entity) != EntityType.Player)
                    {
                        return;
                    }
                    foreach (var c in PlayerManager.Players)
                    {
                        if (c.Client != entity)
                        {
                            continue;
                        }
                    }
                };
                ArrestLocation.ColZone.OnEntityEnterColShape += (shape, entity) =>
                {
                    if (API.Shared.GetEntityType(entity) != EntityType.Player)
                    {
                        return;
                    }
                    foreach (var c in PlayerManager.Players)
                    {
                        if (c.Client != entity)
                        {
                            continue;
                        }
                    }
                };
            }
        }
 public void BeforeEachTest()
 {
     _frontDesk = new FrontDesk();
 }
Example #13
0
 public Chef(FrontDesk frontDesk, IChefActions chefActions)
 {
 }