Ejemplo n.º 1
0
        public void GetFileContentMockVerify(string id)
        {
            Mock <IDBManager> databaseMock = new Mock <IDBManager>();

            databaseMock.Setup(database => database.GetContent(id)).Verifiable();

            fileContentController = new FileContentController(databaseMock.Object);

            fileContentController.GetContent(id);

            databaseMock.Verify(database => database.GetContent(id), Times.Once);
        }
        public UpdatingDatabase(Files file, FileContent fileContent, IController ic)
        {
            Delta delta = new Delta();

            fileController        = new FileController();
            fileContentController = new FileContentController();

            deltaController = new DeltaController();

            delta = null;

            if (fileController.FileExists(file.Id))
            {
                Console.WriteLine("FILE EXISTS IN DATABASE!!");
                Console.WriteLine("We will now start processing for the changes...");

                string databaseContent = fileContentController.GetContent(file.Id);

                if (databaseContent != fileContent.Content)
                {
                    CompareFiles cf = new CompareFiles(deltaController);
                    delta = cf.Compare(fileContent.Content, databaseContent, file.Id);
                }

                if (delta != null)
                {
                    UpdateFileContent(fileContentController, fileContent, file.Id);
                    SendDeltaInformation sd = new SendDeltaInformation(ic);
                    sd.Send(delta, databaseContent);
                }
                else
                {
                    Console.WriteLine("-------------------------------");
                    Console.WriteLine("No changes! File contents are completely the same");
                    Console.WriteLine("-------------------------------");
                }
            }
            else
            {
                Console.WriteLine("File doesn't Exists in database. Now we are going to add it");
                AddToDatabase(file, fileContent, fileController, fileContentController);
            }
        }