Exemplo n.º 1
0
        private static void GetMonitorsBasedOnSpecs()
        {
            Bot.PrintLine("These are the different specifications present ");
            string AllSpec1 = Logic.GetAllSpec("Spec1");
            string AllSpec2 = Logic.GetAllSpec("Spec2");

            Bot.PrintData(AllSpec1);
            string spec1num = Bot.Prompt("Please select the specification in the above category which you want to search for");
            string spec1    = Logic.ReturnSpec(Int32.Parse(spec1num), "Spec1");

            Bot.PrintData(AllSpec2);
            string spec2num = Bot.Prompt("Please select the specification in the above category which you want to search for");
            string spec2    = Logic.ReturnSpec(Int32.Parse(spec2num), "Spec2");

            Bot.PrintLine("Model Numbers with your required specifications are: ");
            string modelsOnSpecs = MonitorAccessor.GetModelOnSpecifications(spec1, spec2);

            Bot.PrintData(modelsOnSpecs);
            string modelNameSentence = Bot.Prompt("Select the model you want to inquire about");
            string modelName         = Logic.ExtractKeyword(modelsOnSpecs, modelNameSentence).ToUpper();

            while (true)
            {
                while (!modelsOnSpecs.Contains(modelName))
                {
                    modelNameSentence = Bot.Prompt(
                        "The model you selected does not have the specification which you specified or is not available with us. Please enter the model name which has {0} as the specification");
                    modelName = Logic.ExtractKeyword(modelsOnSpecs, modelNameSentence).ToUpper();
                }
                Bot.PrintData(MonitorAccessor.GetSpecification(modelName));
                string buyMonitor = Bot.Prompt("Do you want to select this product?");
                if (buyMonitor.Contains("yes"))
                {
                    cart.Monitors.Add(modelName);
                    Bot.PrintLine("The product is successfully added to your cart.");
                }
                modelNameSentence = Bot.Prompt("Do you want the full specifications for more models? If Yes, Please specify the Model name.");
                if (modelNameSentence.Contains("what") || modelNameSentence.Contains("show"))
                {
                    Bot.PrintData(modelsOnSpecs);
                    modelNameSentence = Bot.Prompt("Here you go, These are the models of the specification which you specified. Please choose one");
                }
                modelName = Logic.ExtractKeyword(modelsOnSpecs, modelNameSentence).ToUpper();
                if (modelNameSentence.Contains("no"))
                {
                    return;
                }
            }
        }
        public void TestGetModelsOnSpec()
        {
            string models1    = "MX400\nVM1\nVM4";
            string models2    = "MX700\nMX800\nCM SERIES";
            string models3    = "MP5\nVSI";
            string test1spec2 = "9 Inch Touch Screen";
            string test1spec1 = "Portable";
            string test2spec2 = "15 Inch Touch Screen";
            string test2spec1 = "Non-Portable";
            string test3spec2 = "5.5 Inch Touch Screen";
            string test3spec1 = "Portable";

            Assert.AreEqual(models1, MonitorAccessor.GetModelOnSpecifications(test1spec1, test1spec2));
            Assert.AreEqual(models2, MonitorAccessor.GetModelOnSpecifications(test2spec1, test2spec2));
            Assert.AreEqual(models3, MonitorAccessor.GetModelOnSpecifications(test3spec1, test3spec2));
        }