Ejemplo n.º 1
0
    public static void Main()
    {
        ConsolePrinter printer = new ConsolePrinter();

        printer.Print(true);
        printer.Print(false);
    }
        /// <summary>
        /// Creates the Comparer of the file.
        /// </summary>
        /// <param name="myStructure">Structure to extract the data.</param>
        /// <param name="paramA">Parameter to extract info to make a part of the function's sign.</param>
        /// <param name="streamText">A stringBuilder to write the data.</param>
        /// <param name="packsDone">Amount of steps done.</param>
        /// <param name="fullPackSize">Amount of total steps to do.</param>
        /// <returns>The amount of steps done.</returns>
        protected override short CreateComparer(Structure myStructure, Parameter paramA, StringBuilder streamText, short packsDone, short fullPackSize)
        {
            streamText.AppendLine($"int {myStructure.AliasName}_compare{paramA.AliasNameParameter}(void* this1, void* this2);");
            packsDone++;
            ConsolePrinter.ShowProgress(fullPackSize, packsDone);

            return(packsDone);
        }
        /// <summary>
        /// Creates the function that show all entities of structures.
        /// </summary>
        /// <param name="myStructure">Structure to extract the data.</param>
        /// <param name="streamText">A stringBuilder to write the data.</param>
        /// <param name="packsDone">Amount of steps done.</param>
        /// <param name="fullPackSize">Amount of total steps to do.</param>
        /// <returns>The amount of steps done.</returns>
        protected override short ShowAllEntities(Structure myStructure, StringBuilder streamText, short packsDone, short fullPackSize)
        {
            streamText.AppendLine($"int {myStructure.AliasName}_showAll(LinkedList* this, char* errorMesage);\n");
            packsDone++;
            ConsolePrinter.ShowProgress(fullPackSize, packsDone);

            return(packsDone);
        }
        /// <summary>
        /// Creates the Getter of the file.
        /// </summary>
        /// <param name="myStructure">Structure to extract the data.</param>
        /// <param name="paramA"></param>
        /// <param name="streamText">A stringBuilder to write the data.</param>
        /// <param name="packsDone">Amount of steps done.</param>
        /// <param name="fullPackSize">Amount of total steps to do.</param>
        /// <returns>The amount of steps done.</returns>
        protected override short CreateGetter(Structure myStructure, Parameter paramA, StringBuilder streamText, short packsDone, short fullPackSize)
        {
            streamText.AppendLine($"int {myStructure.AliasName}_get{paramA.AliasNameParameter}({myStructure.FinalStructureName}* this, {paramA.TypeParameter}* {paramA.NameParameter});");
            packsDone++;
            ConsolePrinter.ShowProgress(fullPackSize, packsDone);

            return(packsDone);
        }
        /// <summary>
        /// Creates the function that show an entity of the structures.
        /// </summary>
        /// <param name="myStructure">Structure to extract the data.</param>
        /// <param name="streamText">A stringBuilder to write the data.</param>
        /// <param name="packsDone">Amount of steps done.</param>
        /// <param name="fullPackSize">Amount of total steps to do.</param>
        /// <returns>The amount of steps done.</returns>
        protected override short ShowOneEntity(Structure myStructure, StringBuilder streamText, short packsDone, short fullPackSize)
        {
            streamText.AppendLine($"void {myStructure.AliasName}_show({myStructure.FinalStructureName}* this);"); // void usr_show(sUser* user)
            packsDone++;
            ConsolePrinter.ShowProgress(fullPackSize, packsDone);

            return(packsDone);
        }
Ejemplo n.º 6
0
        public void TestSetAndReturnConsolePrinter()
        {
            var consolePrinter = new ConsolePrinter();

            consolePrinter.Value(printValueTestValue);

            Assert.AreEqual(printValueTestValue, ConsolePrinter.PrintValue);
        }
Ejemplo n.º 7
0
        public NodeEntity GetSubNode(NodeEntity parentFolder, string subFolderName, TypeEnum nodeType, out bool haveCreated, bool cached = true, string subFolderPassword = "******")
        {
            var key = $"{parentFolder.Key}.{subFolderName}";

            haveCreated = false;
            if (cached && _cache.ContainsKey(key))
            {
                ConsolePrinter.Write(ConsoleColor.Green, $"Loaded {nodeType} : {subFolderName} (cached)");
                return(_cache[key]);
            }

            var subFolder = parentFolder.GetChildrenAsync(type: nodeType).Result?.FirstOrDefault(f => string.Equals(f.Name, subFolderName, StringComparison.CurrentCultureIgnoreCase));

            if (subFolder != null)
            {
                subFolder.Key = key;
                if (!_cache.ContainsKey(key))
                {
                    _cache.Add(key, subFolder);
                }
                else
                {
                    _cache[key] = subFolder;
                }

                ConsolePrinter.Write(ConsoleColor.Green, $"Loaded {nodeType} : {subFolderName}");
                return(subFolder);
            }

            ConsolePrinter.Write(ConsoleColor.DarkYellow, $"Creating {nodeType} : {subFolderName}");

            //we need to create it
            subFolder = new NodeEntity(_oauthToken)
            {
                Type         = nodeType,
                Description  = subFolderName,
                Name         = subFolderName,
                UrlName      = subFolderName,
                Keywords     = new[] { subFolderName },
                Parent       = parentFolder,
                Privacy      = subFolderPassword == "NONE" ? PrivacyEnum.Public : PrivacyEnum.Unlisted,
                SecurityType = subFolderPassword == "NONE" ? SecurityTypeEnum.None : SecurityTypeEnum.Password,
                Password     = subFolderPassword == "NONE" ? null : subFolderPassword,
                PasswordHint = subFolderPassword == "NONE" ? null : "It's on your sales reciept",
                Key          = key
            };

            subFolder.CreateAsync(parentFolder).Wait();
            haveCreated = true;

            //Read it back in so we got all properties
            subFolder     = parentFolder.GetChildrenAsync(type: nodeType).Result?.FirstOrDefault(f => string.Equals(f.Name, subFolderName, StringComparison.CurrentCultureIgnoreCase));
            subFolder.Key = key;

            _cache.Add(key, subFolder);

            return(subFolder);
        }
Ejemplo n.º 8
0
        public static void PrintToConsole(BTree <int> tree)
        {
            Console.WriteLine("\n\nPrinting to Console.");
            PrintParentIndetifier();
            ConsolePrinter     printer     = new ConsolePrinter();
            BTreePrinter <int> treePrinter = new BTreePrinter <int>(printer);

            treePrinter.PrintBTree(tree);
        }
        public void Main()
        {
            IPrinter  _printer    = new ConsolePrinter();
            Reflector reflector   = new Reflector("printer");
            var       types       = reflector.GetAllTypes();
            var       Fileprinter = reflector.CreateInstance("FilePrinter", null);

            _printer.PrintLine("Got instance of FilePrinter from reflection class");
        }
Ejemplo n.º 10
0
        public static Shell DefaultShell()
        {
            var consoleReader  = new ConsoleReader();
            var commandParser  = new CommandParser();
            var inputParser    = new InputParser(consoleReader);
            var consolePrinter = new ConsolePrinter();

            return(new Shell(commandParser, inputParser, consolePrinter));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates The Constructor of the structure without parameters.
        /// </summary>
        /// <param name="myStructure">Structure to extract the data.</param>
        /// <param name="streamText">A stringBuilder to write the data.</param>
        /// <param name="packsDone">Amount of steps done.</param>
        /// <param name="fullPackSize">Amount of total steps to do.</param>
        /// <returns>The amount of steps done.</returns>
        protected override short CreateBuilderEmpty(Structure myStructure, StringBuilder streamText, short packsDone, short fullPackSize)
        {
            // Empty builder
            streamText.AppendLine($"{myStructure.FinalStructureName}* {myStructure.AliasName}_newEmpty();"); // auxStrName* strShort_newEmpty();
            packsDone++;
            ConsolePrinter.ShowProgress(fullPackSize, packsDone);

            return(packsDone);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates in the stream the basic builder of the structure.
        /// </summary>
        /// <param name="myStructure">Structure to extract the data.</param>
        /// <param name="streamText">A stringBuilder to write the data.</param>
        /// <param name="packsDone">Amount of steps done.</param>
        /// <param name="fullPackSize">Amount of total steps to do.</param>
        /// <returns>The amount of steps done.</returns>
        protected override short CreateBuilderEmpty(Structure myStructure, StringBuilder streamText, short packsDone, short fullPackSize)
        {
            streamText.AppendLine($"{myStructure.FinalStructureName}* {myStructure.AliasName}_newEmpty(){{");
            streamText.AppendLine($"\treturn ({myStructure.FinalStructureName}*) calloc(sizeof({myStructure.FinalStructureName}),1);\n}}\n");
            packsDone++;
            ConsolePrinter.ShowProgress(fullPackSize, packsDone);

            return(packsDone);
        }
Ejemplo n.º 13
0
        private void CompareSpellLocation(Spell spell, Vector2 pos, float time)
        {
            var pos2 = spell.CurrentSpellPosition;

            if (spell.SpellObject != null)
            {
                ConsolePrinter.Print("Compare: " + pos2.Distance(pos) / (Environment.TickCount - time));
            }
        }
Ejemplo n.º 14
0
        private void Game_OnDoCast(Obj_AI_Base sender, Obj_AI_BaseMissileClientDataEventArgs args)
        {
            if (!TestMenu["(ShowDoCastInfo)"].Enabled)
            {
                return;
            }

            ConsolePrinter.Print("DoCast " + sender.Name + ": " + args.SpellData.Name);
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            IRepository <Emploee> repo       = new EmploeeRepository(@"..\..\..\..\Emploees.txt");
            IPrinter printer                 = new ConsolePrinter();
            IEmploeeSearchService empSrevice = new EmploeeSearchService(repo);
            IRunner empRunner                = new EmploeeSearchRunner(printer, empSrevice);

            empRunner.Start();
        }
        public static EquationInfo PrintReduceForm(this EquationInfo equationInfo)
        {
            var colection = equationInfo
                            .ToCollection();

            ConsolePrinter.Info($"Reduced Form: {PrintFirst(colection)}{PrintOther(colection)} = 0{Environment.NewLine}");

            return(equationInfo);
        }
Ejemplo n.º 17
0
        public static void Main()
        {
            var reader  = new ConsoleReaderProvider();
            var printer = new ConsolePrinter();

            var service = new BusinessLogicService();

            service.Execute(reader, printer);
        }
Ejemplo n.º 18
0
        //NativeHooksLoader t1clr = new NativeHooksLoader();



        public Main(RemoteHooking.IContext InContext, MessageFromInjector message)
        {
            ConsolePrinter.writeMessage("Console allocated");
            //AssemblyName an = AssemblyName.GetAssemblyName("z:\\HookingProjects\\APIMonitoring\\Debug\\AlmostNativeHooks.dll");
            //AssemblyName an_1 = AssemblyName.GetAssemblyName("z:\\HookingProjects\\APIMonitoring\\Debug\\msvcm90d.dll");
            //System.Reflection.Assembly.Load(an_1);
            //assembly_1=System.Reflection.Assembly.Load(an);
            tu_sender = new TransferUnitSender_New(message.channel_name);
        }
Ejemplo n.º 19
0
        public static void Main(string[] args)
        {
            IPrinter printer = new ConsolePrinter();

            if (args.Length < 1)
            {
                printer.printLine("Nothing to compile.");
                printer.printLine("Please supply the Mini-Pascal source code file as the first argument when running this program.");
                printer.printLine("If you want to save the the translation to a file, please supply the target file name as the second argument.");
                return;
            }

            string sourceFilename = @args [0];

            if (!
                File.Exists(sourceFilename))
            {
                printer.printLine(String.Format("Unable to open the source file {0}.\n", sourceFilename));
                return;
            }

            CompilerFrontend cf   = new CompilerFrontend();
            SyntaxTree       tree = cf.Compile(sourceFilename);

            if (cf.getErrors().Count > 0)
            {
                printer.printLine(String.Format("The following errors were encountered during compilation of file {0}:\n", sourceFilename));
                printer.SourceLines = cf.SourceLines;
                printer.printErrors(cf.getErrors());
                return;
            }

            printer.printLine(String.Format("Translation of the file {0} from Mini-Pascal to an AST finished succesfully.", sourceFilename));

            SimplifiedCSynthesizer synthesizer = new SimplifiedCSynthesizer(tree);
            List <string>          translation = synthesizer.Translate();

            printer = new ConsolePrinter(translation.ToArray());

            if (args.Length > 1)
            {
                string targetFilename = @args [1];
                bool   fileWritten    = FileWriter.writeListToFile(translation, targetFilename);

                if (fileWritten)
                {
                    printer.printLine(String.Format("Synthesis of the AST to Simplified C was successfully written to {0}.\n", targetFilename));
                    return;
                }

                printer.printLine(String.Format("Unable to write to the target file {0}.\n", targetFilename));
            }

            printer.printLine("Synthesis of the AST to Simplified C:\n");
            printer.printSourceLines();
        }
Ejemplo n.º 20
0
            public IPrinter Create(ILogRegistry registry, LogConfig config)
            {
                creationCounter.Increment("console");

                var printer = new ConsolePrinter();

                printer.SetRegistry(registry);
                printer.SetConfig(config);
                return(printer);
            }
Ejemplo n.º 21
0
        private static List <string> GetFiles(string path, string pattern)
        {
            if (!Directory.Exists(path))
            {
                ConsolePrinter.Write(ConsoleColor.Yellow, $"Path does not exists - {path}");
                return(new List <string>());
            }

            return(Directory.GetFiles(path, pattern).Where(f => !f.ToLower().Contains("facebook")).ToList());
        }
        public void PrintInvalidEntryMessagePrintsCorrectMessage()
        {
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();

            var expected = GlobalMessages.IncorrectGuessOrCommand + Environment.NewLine;
            printer.PrintInvalidEntryMessage();

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        public void PrintEnterLetterOrCommandMessageIsCorrect()
        {
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();

            var expected = GlobalMessages.EnterLetterOrCommand;
            printer.PrintEnterLetterOrCommandMessage();

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        public void PrintLetterAlreadyRevealedMessageIsCorrect()
        {
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();

            var expected = "The letter you have entered is already revealed!" + Environment.NewLine;
            printer.PrintLetterAlreadyRevealedMessage();

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        /// <summary>
        /// Creates The Constructor of the structure without parameters.
        /// </summary>
        /// <param name="myStructure">Structure to extract the data.</param>
        /// <param name="streamText">A stringBuilder to write the data.</param>
        /// <param name="packsDone">Amount of steps done.</param>
        /// <param name="fullPackSize">Amount of total steps to do.</param>
        /// <returns>The amount of steps done.</returns>
        protected override short CreateBuilderEmpty(Structure myStructure, StringBuilder streamText, short packsDone, short fullPackSize)
        {
            streamText.Append($"\n// ## {myStructure.FinalStructureName}: BASIC STRUCTURE FUNCTIONS.\n");
            // Empty builder
            streamText.Append($"{myStructure.FinalStructureName}* {myStructure.AliasName}_newEmpty();\n"); // auxStrName* strShort_newEmpty();
            packsDone++;
            ConsolePrinter.ShowProgress(fullPackSize, packsDone);

            return(packsDone);
        }
Ejemplo n.º 26
0
        private ConsolePrinter CreateConsolePrinter()
        {
            //XXX Should we just use a factory?

            var printer = new ConsolePrinter(ElementFactory);

            printer.SetConfig(logConfig);
            printer.SetRegistry(logRegistry);
            return(printer);
        }
Ejemplo n.º 27
0
        public void Main()
        {
            IPrinter printer = new ConsolePrinter();
            IReader  reader  = new ConsoleReader();
            int      n;
            int      m;
            int      threadCount;

            printer.PrintLine("Task on threads\nEnter size of matrix to generate and to find the sum of all elements");
            while (true)
            {
                try
                {
                    printer.PrintLine("Enter n:");
                    n = Convert.ToInt32(reader.ReadLine());
                    printer.PrintLine("Enter m:");
                    m = Convert.ToInt32(reader.ReadLine());
                    break;
                }
                catch
                {
                    printer.PrintLine("You entered wrong size. Try again\n");
                }
            }
            var matrix = new Matrix(n, m);

            while (true)
            {
                try
                {
                    printer.PrintLine("Enter a number of threads:");
                    threadCount = Convert.ToInt32(reader.ReadLine());
                    break;
                }
                catch
                {
                    printer.PrintLine("You entered wrong number of threads. Try again\n");;
                }
            }

            var threads = new Threads(threadCount);

            var watch = new Stopwatch();

            watch.Start();
            int sumFromThreads = threads.GetSumOfMatrixElements(matrix);

            watch.Stop();

            printer.PrintLine("sum from threads = " + sumFromThreads);
            var _sum = matrix.GetSumOfAllElements();

            printer.PrintLine("real sum = " + _sum);
            printer.PrintLine("Execution time = " + watch.ElapsedMilliseconds + " ms");
        }
Ejemplo n.º 28
0
        public void PrintInvalidEntryMessagePrintsCorrectMessage()
        {
            var printer       = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();

            var expected = GlobalMessages.IncorrectGuessOrCommand + Environment.NewLine;

            printer.PrintInvalidEntryMessage();

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
Ejemplo n.º 29
0
        public void PrintLetterAlreadyRevealedMessageIsCorrect()
        {
            var printer       = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();

            var expected = "The letter you have entered is already revealed!" + Environment.NewLine;

            printer.PrintLetterAlreadyRevealedMessage();

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Task2"/> class.
 /// </summary>
 public Task2()
 {
     if (configuration.GetConnectionString("Output") == "Console")
     {
         Printer = new ConsolePrinter();
     }
     else
     {
         Printer = new FilePrinter();
     }
 }
Ejemplo n.º 31
0
        private static void WriteEnums()
        {
            Dictionary <string, string> enumTypeDefs = CodeGen.BuildEnums();

            foreach (var item in enumTypeDefs)
            {
                File.WriteAllText(Path.Combine(_options.OutputDirEnums, item.Key + "Enum.cs"), item.Value);
                ConsolePrinter.Write(ConsoleColor.Green, "Generated enum {0}", item.Key);
            }
            ConsolePrinter.Write(ConsoleColor.White, "Generated {0} enums", enumTypeDefs.Count);
        }
Ejemplo n.º 32
0
        public void PrintEnterLetterOrCommandMessageIsCorrect()
        {
            var printer       = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();

            var expected = GlobalMessages.EnterLetterOrCommand;

            printer.PrintEnterLetterOrCommandMessage();

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        public void Create_CurriculumVitae_Minimum_Information_Successfully()
        {
            // Create Curriculum Vitae using CurriculumVitae builder
            CurriculumVitae curriculum = CVBuilder.Core.CurriculumVitaeBuilder
                                         .Start()
                                         .WithFirstName("Daniel")
                                         .WithLastName("Bran")
                                         .WithPhoneNumber("0040734***375")
                                         .WithEmail("bran******@gmail.com")
                                         .WithAddress()
                                         .WithCountry("Romania")
                                         .WithCounty("Bihor")
                                         .WithCity("Oradea")
                                         .Update()
                                         .WithLanguage("English")
                                         .WithLanguage("Spanish")
                                         .WithLanguage("Romanian")
                                         .WithNationaity("Romanian")
                                         .WithEducationItem(
                new Education()
            {
                Id          = 1,
                Title       = "Coumputer Science Faculty",
                Description = "Coumputer Science Faculty at University of Oradea"
            })
                                         .WithEducationItem(
                new Education()
            {
                Id          = 2,
                Title       = "Master of Computer Science",
                Description = "Master of Computer Science at University of Oradea, theme Distributed systems in internet"
            })
                                         .WithBirthday(DateTime.Now.AddYears(-18))
                                         .AddPhoto("https://media-exp1.licdn.com/dms/image/C5103AQGKJtoudXZHSg/profile-displayphoto-shrink_200_200/0?e=1584576000&v=beta&t=B1EuznIzsSR6CEJVoSzXEzIAJudSsIpC8Ky8_EGqBnw")
                                         .Finish();

            // Create new console printer to display the curriculum into Test output.
            ConsolePrinter consolePrinter = new ConsolePrinter();

            // Print CV into Test output.
            consolePrinter.Print(curriculum);

            // Test asserts
            Assert.AreEqual(curriculum.FullName, "Daniel Bran");
            Assert.AreEqual(curriculum.PhoneNumber, "0040734***375");
            Assert.AreEqual(curriculum.EmailAddress, "bran******@gmail.com");
            Assert.AreEqual(curriculum.Address.Country, "Romania");
            Assert.AreEqual(curriculum.Address.County, "Bihor");
            Assert.AreEqual(curriculum.Address.City, "Oradea");
            Assert.IsTrue(curriculum.Languages.Count == 3);
            Assert.AreEqual(curriculum.Nationality, "Romanian");
            Assert.IsTrue(curriculum.Educations.ToList().Count == 2);
            Assert.Pass();
        }
        /// <summary>
        /// Creates the setters of all the parameters of the structure.
        /// </summary>
        /// <param name="myStructure">Structure to extract the data.</param>
        /// <param name="streamText">A stringBuilder to write the data.</param>
        /// <param name="packsDone">Amount of steps done.</param>
        /// <param name="fullPackSize">Amount of total steps to do.</param>
        /// <returns>The amount of steps done.</returns>
        private short CreateSetters(Structure myStructure, StringBuilder streamText, short packsDone, short fullPackSize)
        {
            foreach (Parameter aParam in myStructure.ListParamaters)
            {
                packsDone = CreateSetter(myStructure, aParam, streamText, packsDone, fullPackSize);
            }
            packsDone++;
            ConsolePrinter.ShowProgress(fullPackSize, packsDone);

            return(packsDone);
        }
        public void ConsolePrinterPrintLine_WhenAStringIsPassed_ShouldPrintTheStringWithNewLine()
        {
            // arrange
            var text = "To be printed";
            var printer = new ConsolePrinter();

            // act
            printer.PrintLine(text);

            // assert
            var actual = this.stringWriter.ToString();
            var expected = text + Environment.NewLine;

            Assert.AreEqual(expected, actual);
        }
        public void ConsolePrinterClearScreen_WhenSomethingIsPrinted_ShouldClearIt()
        {
            // arrange
            var printer = new ConsolePrinter();
            printer.PrintLine();
            printer.PrintLine("Test line");
            printer.PrintLine();
            printer.Print("Test");

            // act
            printer.ClearScreen();

            // assert
            var actual = this.stringWriter.ToString();
            var expected = string.Empty;

            Assert.AreEqual(expected, actual);
        }
        public void PrintAllRecordsIsCorrect()
        {
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();

            var expected = GlobalMessages.HighScores + Environment.NewLine;

            for (int i = 0; i < fakeTopFiveRecords.Count; i++)
            {
                string name = fakeTopFiveRecords[i].PlayerName;
                uint mistakes = fakeTopFiveRecords[i].Score;
                expected += string.Format(GlobalMessages.ScoreFormat, i + 1, name, mistakes) + Environment.NewLine;
            }

            printer.PrintAllRecords(fakeTopFiveRecords);

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        public void ConsolePrinterPrint_WhenNullIsPassed_ShouldPrintEmptyString()
        {
            // arrange
            string text = null;
            var printer = new ConsolePrinter();

            // act
            printer.Print(text);

            // assert
            var actual = this.stringWriter.ToString();
            var expected = string.Empty;

            Assert.AreEqual(expected, actual);
        }
        public void ConsolePrinterPrint_WhenASingleSymbolStringIsPassed_ShouldPrintTheStringWithoutNewLine()
        {
            // arrange
            var text = "t";
            var printer = new ConsolePrinter();

            // act
            printer.Print(text);

            // assert
            var actual = this.stringWriter.ToString();
            var expected = text;

            Assert.AreEqual(expected, actual);
        }
        public void WriteVanWriteAnyMessage()
        {
            string message = "Abrakadabra";
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();

            var expected = message + Environment.NewLine;
            printer.Write(message);

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        public void PrintWelcomeMessagePtintsCorrectMessage()
        {
            var printer = new ConsolePrinter();
            var expected = GlobalMessages.Welcome + Environment.NewLine +
                GlobalMessages.CommandOptions + Environment.NewLine;

            var consoleOutput = new ConsoleOutput();
            printer.PrintWelcomeMessage();
            Assert.AreEqual(expected, consoleOutput.GetOuput());

            //var fakerPrinter = new Mock<IPrinter>();
            //fakerPrinter.Setup(p => p.PrintWelcomeMessage());
            //fakerPrinter.Object.PrintWelcomeMessage();
            //fakerPrinter.Verify(p => p.PrintWelcomeMessage(), Times.AtLeast(2));
        }
Ejemplo n.º 42
0
        public void TestAddMultipleProductsToShoppingCartAndPrintBill()
        {
            var lPrinter = new ConsolePrinter();
            var lBs = new BarcodeScannerDataProcessor(_mPoducts, _mDisplay, lPrinter);

            lBs.Scan("apple");
            lBs.Scan("orange");
            lBs.Scan("kiwi");
            lBs.Scan("grapes");

            string lsBill = lPrinter.PrintBill(_mDisplay.ShoppingCart);

            Assert.AreEqual("$34GP\r\n$36GP\r\n$19G\r\n$98G\r\nSubtotal: 187\r\nGST: 9.35\r\nPST: 5.60\r\n------\r\nTOTAL: 201.95\r\n", lsBill);
        }
        public void PrintNoRevealedLettersMessageIsCorrect()
        {
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();
            char revealedLetter = 'A';

            var expected = string.Format(GlobalMessages.LetterNotRevealed, revealedLetter) + Environment.NewLine;
            printer.PrintNoRevealedLettersMessage(revealedLetter);

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        public void PrintWinMessageIsCorrectWhenHelpNotUsed()
        {
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();
            uint mistakesCount = 3;

            var mockScoreboard = new Mock<IScoreboard>();
            mockScoreboard.Setup(m => m.TopFiveRecords).Returns(this.fakeTopFiveRecords);
            char[] wordToGuess = "tralala".ToCharArray();

            var expected = GlobalMessages.SecretWord + string.Join(" ", wordToGuess) + " "
                + Environment.NewLine + string.Format(GlobalMessages.Win, mistakesCount) + Environment.NewLine;
            printer.PrintWinMessage(mistakesCount, false, mockScoreboard.Object, wordToGuess);

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        public void PrintNumberOfRevealedLettersIsCorrectForManyLetters()
        {
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();
            int revealedLettersCount = 3;

            var expected = string.Format(GlobalMessages.MultipleLettersRevealed, revealedLettersCount) + Environment.NewLine;
            printer.PrintNumberOfRevealedLetters(revealedLettersCount);

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
        public void PrintWordToGuessPrintsCorrectMessage()
        {
            var printer = new ConsolePrinter();
            var consoleOutput = new ConsoleOutput();
            char[] wordToGuess = "tralala".ToCharArray();

            var expected = GlobalMessages.SecretWord + string.Join(" ", wordToGuess) + " " + Environment.NewLine;
            printer.PrintWordToGuess(wordToGuess);

            Assert.AreEqual(expected, consoleOutput.GetOuput());
        }
Ejemplo n.º 47
0
 /// <summary>
 /// The entry point of the program.
 /// </summary>
 private static void Main()
 {
     ConsolePrinter consolePrinter = new ConsolePrinter();
     consolePrinter.Print(true);
 }
Ejemplo n.º 48
0
 static void Main()
 {
     var logger = new ConsolePrinter();
     logger.Print("Invalid operation exception");
 }
Ejemplo n.º 49
0
 /// <summary>
 ///     The main method.
 /// </summary>
 public static void Main()
 {
     ConsolePrinter consolePrinter = new ConsolePrinter();
     consolePrinter.PrintVariable(true);
 }
        public void ConsolePrinterPrintLine_WhenNoStringIsPassed_ShouldPrintOnlyNewLine()
        {
            // arrange
            var printer = new ConsolePrinter();

            // act
            printer.PrintLine();

            // assert
            var actual = this.stringWriter.ToString();
            var expected = Environment.NewLine;

            Assert.AreEqual(expected, actual);
        }