public void UpdateFileContent(IFileContentController fcc, FileContent fc, string fileId)
        {
            string fileContentId = fcc.GetFileContentId(fileId);

            fc.Id = fileContentId;
            fcc.UpdateFileContent(fc);
        }
        public void UpdatingDatabaseGood()
        {
            Mock <FileContent> fileContentDouble = new Mock <FileContent>();

            fileContent = fileContentDouble.Object;

            Mock <IFileContentController> fileContentContrellerDouble = new Mock <IFileContentController>();

            fileContentController = fileContentContrellerDouble.Object;

            Mock <Files> fileDouble = new Mock <Files>();

            fileDouble.Setup(fileproba => fileproba.Id).Returns("nestoBezveze");
            file = fileDouble.Object;

            Mock <IFileController> fileContrellerDouble = new Mock <IFileController>();

            fileContrellerDouble.Setup(controller => controller.Add(file)).Verifiable();


            Mock <IController> controllerDouble = new Mock <IController>();

            controller = controllerDouble.Object;

            UpdatingDatabase UpdateDouble = new  UpdatingDatabase();

            UpdateDouble.AddToDatabase(file, fileContent, fileContrellerDouble.Object, fileContentController);

            fileContrellerDouble.Verify(controller => controller.Add(file), Times.Once);
        }
Пример #3
0
        public void GetFileContentIdMockVerify(string id)
        {
            Mock <IDBManager> databaseMock = new Mock <IDBManager>();

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

            fileContentController = new FileContentController(databaseMock.Object);

            fileContentController.GetFileContentId(id);

            databaseMock.Verify(database => database.GetFileContentId(id), Times.Once);
        }
Пример #4
0
        public void UpdateFileContentMockVerify()
        {
            Mock <IDBManager> databaseMock = new Mock <IDBManager>();

            databaseMock.Setup(database => database.UpdateFileContent(fileContent)).Verifiable();

            fileContentController = new FileContentController(databaseMock.Object);

            fileContent.FileId  = "nesto";
            fileContent.Content = "nesto2";
            fileContent.Id      = "1,";
            fileContentController.UpdateFileContent(fileContent);

            databaseMock.Verify(database => database.UpdateFileContent(fileContent), 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);
            }
        }
 public void AddToDatabase(Files file, FileContent fileContent, IFileController fc, IFileContentController fcc)
 {
     fc.Add(file);
     fcc.Add(fileContent);
 }