コード例 #1
0
        public void ConstructorOK()
        {
            var settings = new PictureServiceSettings()
            {
                Dates = new[] { "1/1/2019" }
            };

            _service = new PictureService(_proxy.Object, new DefaultHttpClientFactory(), new MemoryCache(new MemoryCacheOptions()),
                                          settings, null, _fs.Object, _env.Object);
        }
コード例 #2
0
        public void ConstructorFail()
        {
            var settings = new PictureServiceSettings()
            {
                Dates = new[] { "not a date" }
            };

            Assert.ThrowsAny <InvalidOperationException>(() =>
                                                         new PictureService(_proxy.Object, new DefaultHttpClientFactory(), new MemoryCache(new MemoryCacheOptions()),
                                                                            settings, null, _fs.Object, _env.Object));
        }
コード例 #3
0
 public PictureServiceTests()
 {
     _fixture = new Fixture();
     _proxy   = new Mock <INasaApiProxy>();
     _file    = new Mock <IFile>();
     _fs      = new Mock <IFileSystem>();
     _fs.Setup(s => s.File).Returns(_file.Object);
     _env = new Mock <IHostingEnvironment>();
     _env.Setup(e => e.WebRootPath).Returns("WebRootPath");
     _settings = new PictureServiceSettings()
     {
         Dates = new[] { "1/1/2019" }
     };
     //use memory cache in an "integration" test mode to save time mocking behavior
     _memoryCache = new MemoryCache(new MemoryCacheOptions());
     _service     = new PictureService(_proxy.Object, new DefaultHttpClientFactory(), _memoryCache,
                                       _settings, null, _fs.Object, _env.Object);
 }