public void FileExistMockVerify(string id)
        {
            Mock <IDBManager> databaseMock = new Mock <IDBManager>();

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

            fileController = new FileController(databaseMock.Object);

            fileController.FileExists(id);

            databaseMock.Verify(database => database.FileExists(id), Times.Once);
        }
        public IEnumerable <IncludedFile> LoadStaticFilenames(string folder)
        {
            CheckFolder(folder, "StaticFiles");

            string filename = folder.PathSlash(ProjectSerialiserV1.StaticFilesDetailsFileName);

            if (controller.FileExists(filename) == false)
            {
                throw new FileNotFoundException(string.Format("Could not find Outputs file at path {0}", filename));
            }
            if (controller.CanReadFile(filename) == false)
            {
                throw new IOException(string.Format("Cannot read from file {0}: Access Denied.", filename));
            }

            string xml = controller.ReadAllText(filename);

            var files = ReadStaticFilesDetails(xml.GetXmlDocRoot());

            SetFullFileNamesForIncludedFiles(files, folder);
            return(files);
        }
        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);
            }
        }
        private XmlDocument GetCSProjDocument(PreGenerationData data, out string filename)
        {
            var doc = new XmlDocument();

            var projectName = data.UserOptions.GetValueOrDefault("ProjectName") as string;

            if (string.IsNullOrEmpty(projectName) == false)
            {
                // Search for the project as named by the ProjectName User Option.
                filename = Path.Combine(data.OutputFolder, projectName + ".csproj");

                if (fileController.FileExists(filename))
                {
                    doc.LoadXml(fileController.ReadAllText(filename));
                    return(doc);
                }
            }

            // If we get to this point, we couldn't find the project in the default location,
            // so we search for the first project that has any *.hbm.xml files in it.
            var csProjFilenames = fileController.FindAllFilesLike(data.OutputFolder, "*.csproj", SearchOption.AllDirectories);

            foreach (var csprojFilename in csProjFilenames)
            {
                doc = new XmlDocument();
                doc.LoadXml(fileController.ReadAllText(csprojFilename));
                var hbmFiles = ProjectLoader.GetHBMFilesFromCSProj(new CSProjFile(doc, csprojFilename), fileController);

                if (hbmFiles.Any())
                {
                    filename = csprojFilename;
                    return(doc);
                }
            }

            filename = "";
            return(null);
        }