コード例 #1
0
        public void Check_File_Exists()
        {
            StubIFileRepository fileRepository = new StubIFileRepository()
            {
                GetItemInt32String = (userId, fileName) =>
                {
                    return new File() { Name = "test", FileId = 100, Status = "Uploaded" };
                }
            };


            IUnitOfWork unitOfWork =
                new Fakes.StubIUnitOfWork()
                {
                    Commit = () => { return; }
                };
            StubIBlobDataRepository blobDataRepository = new StubIBlobDataRepository()
            {
                GetBlobContentString = (name) =>
                {
                    return new DataDetail();
                }
            };
            IRepositoryDetails repositoryDetails = new StubIRepositoryDetails();
            IRepositoryService repositoryService = new StubIRepositoryService();
            IRepositoryAdapterFactory repositoryAdapterFactory = new StubIRepositoryAdapterFactory();

            var fileProvider = new FileServiceProvider(fileRepository, blobDataRepository, unitOfWork, repositoryDetails, repositoryService, repositoryAdapterFactory);
            var result = fileProvider.CheckFileExists("test", 100);
            Assert.AreEqual(true, result);
            Assert.AreEqual(true, true);
        }
コード例 #2
0
        /// <summary>
        /// Returns the instance of SkyDriveFile Service
        /// </summary>
        /// <returns>SkyDriveFileService</returns>
        private SkyDriveFileService GetSkyDriveFileService()
        {

            this.repositoryService = new StubIRepositoryService()
            {
                GetRepositoryByIdInt32 = (repositoryId) =>
                {
                    return this.repository;
                },
            };

            this.userService = new StubIUserService()
             {
                 GetUserAuthTokenInt32Int32 = (userId, RepositoryId) =>
                 {
                     return this.userAuthToken;
                 },

                 AddUpdateAuthTokenAuthToken = authToken =>
                 {
                     return authToken;
                 }
             };

            this.fileRepository = new StubIFileRepository()
            {
                GetItemInt32Int32 = (userId, fileName) =>
                {
                    return new File() { Name = "test", FileId = 100, Status = "Uploaded" };
                },

                UpdateFileFile = (file) =>
                {
                    return file;
                }
            };

            IUnitOfWork unitOfWork =
                new Fakes.StubIUnitOfWork()
                {
                    Commit = () => { return; }
                };

            this.blobDataRepository = new StubIBlobDataRepository()
            {
                GetBlobContentString = (name) =>
                {
                    return new DataDetail();
                },

                DeleteFileString = (fileName) =>
                {
                    return true;
                }
            };


            this.skyDriveAdapter = new StubIRepositoryAdapter()
            {
                PostFilePublishFileModel = (publishFileModel) =>
                    {
                        OperationStatus status = OperationStatus.CreateSuccessStatus();
                        status.CustomReturnValues = "x1234";
                        return status;
                    },

                RefreshTokenString = (accessToken) =>
                    {
                        AuthToken authToken = new AuthToken()
                        {
                            AccessToken = "accessToken",
                            RefreshToken = "refreshToken",
                            TokenExpiresOn = DateTime.UtcNow.AddHours(1)
                        };

                        return authToken;
                    }
            };

            IRepositoryAdapterFactory adapterFactory = new StubIRepositoryAdapterFactory()
            {
                GetRepositoryAdapterString = (baseRepositoryName) =>
                {
                    return skyDriveAdapter;
                }
            };

            this.repositoryDetails = new StubIRepositoryDetails()
            {
                GetRepositoryByIdInt32 = id => new Repository() { BaseRepository = new BaseRepository() { Name = "Repository Type 1" } }
            };

            SkyDriveFileService skyDriveFileService;
            using (ShimsContext.Create())
            {
                ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
                skyDriveFileService = new SkyDriveFileService(fileRepository, blobDataRepository, unitOfWork, repositoryDetails, repositoryService, userService, adapterFactory);
            }

            return skyDriveFileService;
        }