Exemple #1
1
        public void TestResponseMocking()
        {
            var rawResponse = @"HTTP/1.1 200 OK
x-amzn-RequestId: 1111111111111111111111111111111111111111111111111111
x-amz-crc32: 1952885991
Content-Type: application/x-amz-json-1.0
Content-Length: 32
Date: Wed, 29 Jul 2015 01:26:52 GMT

{""TableNames"":[""Images"",""Logs""]}";
            var rawErrorResponse = @"HTTP/1.1 400 Bad Request
x-amzn-RequestId: 2222222222222222222222222222222222222222222222222222
x-amz-crc32: 4224273561
Content-Type: application/x-amz-json-1.0
Content-Length: 140
Date: Tue, 28 Jul 2015 23:51:34 GMT

{""__type"":""com.amazonaws.dynamodb.v20120810#ResourceNotFoundException"",""message"":""Requested resource not found: Table: FakeTable not found""}";

            using (var client = new Amazon.DynamoDBv2.AmazonDynamoDBClient())
            {
                // create mocker and hook it up to a client
                var mocker = new Mocker();
                mocker.AddToClient(client);

                // use raw response
                mocker.RawResponse = rawResponse;

                // make calls and verify data is as expected
                var response = client.ListTables();
                Assert.IsNotNull(response);
                Assert.IsNotNull(response.TableNames);
                Assert.AreEqual(12, response.TableNames.Count);
                Assert.IsNotNull(response.ResponseMetadata);
                Assert.IsNotNull(response.ResponseMetadata.RequestId);
                Assert.AreEqual("1111111111111111111111111111111111111111111111111111", response.ResponseMetadata.RequestId);

                // clear raw response
                mocker.RawResponse = string.Empty;
                // set callback
                mocker.CreateResponseCallback = (httpRequest) =>
                {
                    // create HttpResponse (in this case, from the raw response, but can be created manually)
                    var httpResponse = Mocker.CreateHttpResponse(rawResponse);

                    // modify headers
                    httpResponse.Headers["x-amzn-RequestId"] = "foo!";
                    httpResponse.Headers.Remove("x-amz-crc32");

                    // modify body
                    var json = ThirdParty.Json.LitJson.JsonMapper.ToObject(httpResponse.Body);
                    var tableNames = json["TableNames"];
                    tableNames.Clear();
                    tableNames.Add("Logs");
                    httpResponse.Body = json.ToJson();

                    return httpResponse;
                };

                // make calls and verify data is as expected
                response = client.ListTables();
                Assert.IsNotNull(response);
                Assert.IsNotNull(response.TableNames);
                Assert.AreEqual(1, response.TableNames.Count);
                Assert.AreEqual("Logs", response.TableNames[0]);
                Assert.IsNotNull(response.ResponseMetadata);
                Assert.IsNotNull(response.ResponseMetadata.RequestId);
                Assert.AreEqual("foo!", response.ResponseMetadata.RequestId);

                // clear callback
                mocker.CreateResponseCallback = null;
                // set raw response to error response
                mocker.RawResponse = rawErrorResponse;

                // make call and verify exception is thrown
                var exception = AssertExtensions.ExpectException<Amazon.DynamoDBv2.Model.ResourceNotFoundException>(() => client.DescribeTable("foo"));
                Assert.IsNotNull(exception);
                Assert.IsNotNull(exception.Message);
                Assert.AreEqual("Requested resource not found: Table: FakeTable not found", exception.Message);
                Assert.AreEqual("2222222222222222222222222222222222222222222222222222", exception.RequestId);
            }
        }
Exemple #2
0
        public void Should_Create_Instance_Of_Object_For_Tests()
        {
            var mocker = new Mocker<ObjectUnderTest>();

            mocker.ObjectUnderTest.Should().NotBeNull();
            mocker.ObjectUnderTest.Should().BeOfType<ObjectUnderTest>();
        }
        public void Initialising_Dns_Server_With_No_Listeners_Configured_Throws(IList<IDnsListener> listeners)
        {
            var factory = new Mocker<IDnsListenerFactory>()
                                .With(x => x.CreateListeners(), listeners)
                                .ToEntity();

            new DnsServer(factory);
        }
        public void Factory_Returns_A_Udp_Listener()
        {
            var settings = new Mocker<IDnsServerSettings>().ToEntity();
            var factory = new DnsListenerFactory(settings);
            var hasUdpListener = factory
                                    .CreateListeners()
                                    .Any(listener => listener.GetType() == typeof(UdpListener));

            Assert.That(hasUdpListener, Is.True);
        }
        public void Port_Is_Loaded_From_Settings_Service_With_Default_Value_Of_53()
        {
            var mockSettingsService = new Mocker<ISettingsService>().With(x => x.GetSettingByName("Port", 53), 53);
            var serverSettings = new DnsServerSettings(mockSettingsService.ToEntity());

            var port = serverSettings.Port;

            mockSettingsService.AssertWasCalledOnce(x => x.GetSettingByName("Port", 53));
            Assert.That(port, Is.EqualTo(53));
        }
        public void Starting_Dns_Server_Starts_Listeners()
        {
            var mockListener = new Mocker<IDnsListener>();
            var factory = new Mocker<IDnsListenerFactory>()
                                .With(x => x.CreateListeners(), new List<IDnsListener> { mockListener.ToEntity() })
                                .ToEntity();

            var server = new DnsServer(factory);

            server.StartListening();

            mockListener.AssertWasCalledOnce(x => x.StartListening());
        }
        public void SetupTest()
        {
            _endianessCheckerMocker = new Mocker<IEndianessChecker>()
                                            .With(checker => checker.IsLittleEndianSystem, true);

            _headerBytes = new HeaderBytes();
            _serializer = new MessageSerializer(_endianessCheckerMocker.ToEntity());
        }
Exemple #8
0
        protected override FlowScreenWithLifecycleAdapter <TFlowScreen> BuildAdapter()
        {
            var adapter = new FlowScreenWithLifecycleAdapter <TFlowScreen>(Mocker.CreateInstance <TFlowScreen>(), Fixture);

            return(adapter);
        }
        public void Setup()
        {
            _settings = new TransmissionSettings
            {
                Host     = "127.0.0.1",
                Port     = 2222,
                Username = "******",
                Password = "******"
            };

            Subject.Definition          = new DownloadClientDefinition();
            Subject.Definition.Settings = _settings;

            _queued = new TransmissionTorrent
            {
                HashString    = "HASH",
                IsFinished    = false,
                Status        = TransmissionTorrentStatus.Queued,
                Name          = _title,
                TotalSize     = 1000,
                LeftUntilDone = 1000,
                DownloadDir   = "somepath"
            };

            _downloading = new TransmissionTorrent
            {
                HashString    = "HASH",
                IsFinished    = false,
                Status        = TransmissionTorrentStatus.Downloading,
                Name          = _title,
                TotalSize     = 1000,
                LeftUntilDone = 100,
                DownloadDir   = "somepath"
            };

            _failed = new TransmissionTorrent
            {
                HashString    = "HASH",
                IsFinished    = false,
                Status        = TransmissionTorrentStatus.Stopped,
                Name          = _title,
                TotalSize     = 1000,
                LeftUntilDone = 100,
                ErrorString   = "Error",
                DownloadDir   = "somepath"
            };

            _completed = new TransmissionTorrent
            {
                HashString    = "HASH",
                IsFinished    = true,
                Status        = TransmissionTorrentStatus.Stopped,
                Name          = _title,
                TotalSize     = 1000,
                LeftUntilDone = 0,
                DownloadDir   = "somepath"
            };

            _magnet = new TransmissionTorrent
            {
                HashString    = "HASH",
                IsFinished    = false,
                Status        = TransmissionTorrentStatus.Downloading,
                Name          = _title,
                TotalSize     = 0,
                LeftUntilDone = 100,
                DownloadDir   = "somepath"
            };

            Mocker.GetMock <ITorrentFileInfoReader>()
            .Setup(s => s.GetHashFromTorrentFile(It.IsAny <byte[]>()))
            .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951");

            Mocker.GetMock <IHttpClient>()
            .Setup(s => s.Get(It.IsAny <HttpRequest>()))
            .Returns <HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0]));

            _transmissionConfigItems = new Dictionary <string, object>();

            _transmissionConfigItems.Add("download-dir", @"C:/Downloads/Finished/transmission");
            _transmissionConfigItems.Add("incomplete-dir", null);
            _transmissionConfigItems.Add("incomplete-dir-enabled", false);

            Mocker.GetMock <ITransmissionProxy>()
            .Setup(v => v.GetConfig(It.IsAny <TransmissionSettings>()))
            .Returns(_transmissionConfigItems);
        }
Exemple #10
0
        public void should_not_clean_if_no_movie_was_replaced()
        {
            Subject.OnDownload(_downloadMessage);

            Mocker.GetMock <IXbmcService>().Verify(v => v.Clean(It.IsAny <XbmcSettings>()), Times.Never());
        }
        public void Setup()
        {
            Mocker.GetMock <IConfigService>().Setup(m => m.UILanguage).Returns((int)Language.English);

            Mocker.GetMock <IAppFolderInfo>().Setup(m => m.StartUpFolder).Returns(TestContext.CurrentContext.TestDirectory);
        }
 private void GivenSpecifications <T>(params Mock <IImportDecisionEngineSpecification <T> >[] mocks)
 {
     Mocker.SetConstant(mocks.Select(c => c.Object));
 }
Exemple #13
0
 private void GivenValidQueueItem()
 {
     Mocker.GetMock <ITrackedDownloadService>()
     .Setup(s => s.Find("sab1"))
     .Returns(_trackedDownload);
 }
Exemple #14
0
        public void should_search_for_series_using_folder_name()
        {
            Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));

            Mocker.GetMock <IParsingService>().Verify(c => c.GetSeries("foldername"), Times.Once());
        }
Exemple #15
0
 private void WasImportedResponse()
 {
     Mocker.GetMock <IDiskScanService>().Setup(c => c.GetVideoFiles(It.IsAny <string>(), It.IsAny <bool>()))
     .Returns(new string[0]);
 }
Exemple #16
0
 private void GivenValidSeries()
 {
     Mocker.GetMock <IParsingService>()
     .Setup(s => s.GetSeries(It.IsAny <string>()))
     .Returns(Builder <Series> .CreateNew().Build());
 }
Exemple #17
0
 private void VerifyImport()
 {
     Mocker.GetMock <IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny <List <ImportDecision> >(), true, null, ImportMode.Auto),
                                                       Times.Once());
 }
Exemple #18
0
 private void GivenExistingFileSize(long bytes)
 {
     GivenFileExistsOnDisk();
     Mocker.GetMock <IDiskProvider>().Setup(c => c.GetFileSize(It.IsAny <string>())).Returns(bytes);
 }
Exemple #19
0
 private void GivenFileExistsOnDisk()
 {
     Mocker.GetMock <IDiskProvider>().Setup(c => c.FileExists(It.IsAny <string>())).Returns(true);
 }
Exemple #20
0
 public void Setup()
 {
     _httpResponse = new HttpResponse(null, new HttpHeader(), "", HttpStatusCode.OK);
     Mocker.GetMock <IDiskProvider>().Setup(c => c.GetFileSize(It.IsAny <string>())).Returns(100);
     Mocker.GetMock <IHttpClient>().Setup(c => c.Head(It.IsAny <HttpRequest>())).Returns(_httpResponse);
 }
Exemple #21
0
 private void GivenMetadataProfile(MetadataProfile profile)
 {
     Mocker.GetMock <IMetadataProfileService>().Setup(x => x.Get(profile.Id)).Returns(profile);
 }
Exemple #22
0
        public void should_skip_import_if_dronefactory_doesnt_exist()
        {
            Assert.Throws <ArgumentException>(() => Subject.Execute(new DownloadedAlbumsScanCommand()));

            Mocker.GetMock <IDownloadedTracksImportService>().Verify(c => c.ProcessRootFolder(It.IsAny <IDirectoryInfo>()), Times.Never());
        }
        public void Setup()
        {
            _bookpass1 = new Mock <IImportDecisionEngineSpecification <LocalEdition> >();
            _bookpass2 = new Mock <IImportDecisionEngineSpecification <LocalEdition> >();
            _bookpass3 = new Mock <IImportDecisionEngineSpecification <LocalEdition> >();

            _bookfail1 = new Mock <IImportDecisionEngineSpecification <LocalEdition> >();
            _bookfail2 = new Mock <IImportDecisionEngineSpecification <LocalEdition> >();
            _bookfail3 = new Mock <IImportDecisionEngineSpecification <LocalEdition> >();

            _pass1 = new Mock <IImportDecisionEngineSpecification <LocalBook> >();
            _pass2 = new Mock <IImportDecisionEngineSpecification <LocalBook> >();
            _pass3 = new Mock <IImportDecisionEngineSpecification <LocalBook> >();

            _fail1 = new Mock <IImportDecisionEngineSpecification <LocalBook> >();
            _fail2 = new Mock <IImportDecisionEngineSpecification <LocalBook> >();
            _fail3 = new Mock <IImportDecisionEngineSpecification <LocalBook> >();

            _bookpass1.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalEdition>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Accept());
            _bookpass2.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalEdition>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Accept());
            _bookpass3.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalEdition>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Accept());

            _bookfail1.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalEdition>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Reject("_bookfail1"));
            _bookfail2.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalEdition>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Reject("_bookfail2"));
            _bookfail3.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalEdition>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Reject("_bookfail3"));

            _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalBook>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Accept());
            _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalBook>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Accept());
            _pass3.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalBook>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Accept());

            _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalBook>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Reject("_fail1"));
            _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalBook>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Reject("_fail2"));
            _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny <LocalBook>(), It.IsAny <DownloadClientItem>())).Returns(Decision.Reject("_fail3"));

            _author = Builder <Author> .CreateNew()
                      .With(e => e.QualityProfileId = 1)
                      .With(e => e.QualityProfile   = new QualityProfile {
                Items = Qualities.QualityFixture.GetDefaultQualities()
            })
                      .Build();

            _book = Builder <Book> .CreateNew()
                    .With(x => x.Author = _author)
                    .Build();

            _edition = Builder <Edition> .CreateNew()
                       .With(x => x.Book = _book)
                       .Build();

            _quality = new QualityModel(Quality.MP3_320);

            _localTrack = new LocalBook
            {
                Author  = _author,
                Quality = _quality,
                Book    = new Book(),
                Path    = @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi".AsOsAgnostic()
            };

            _idOverrides = new IdentificationOverrides
            {
                Author = _author
            };

            _idConfig = new ImportDecisionMakerConfig();

            GivenAudioFiles(new List <string> {
                @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi".AsOsAgnostic()
            });

            Mocker.GetMock <IIdentificationService>()
            .Setup(s => s.Identify(It.IsAny <List <LocalBook> >(), It.IsAny <IdentificationOverrides>(), It.IsAny <ImportDecisionMakerConfig>()))
            .Returns((List <LocalBook> tracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) =>
            {
                var ret     = new LocalEdition(tracks);
                ret.Edition = _edition;
                return(new List <LocalEdition> {
                    ret
                });
            });

            Mocker.GetMock <IMediaFileService>()
            .Setup(c => c.FilterUnchangedFiles(It.IsAny <List <IFileInfo> >(), It.IsAny <FilterFilesType>()))
            .Returns((List <IFileInfo> files, FilterFilesType filter) => files);

            GivenSpecifications(_bookpass1);
        }
 private void VerifyNotMonitored(Func <Episode, bool> predicate)
 {
     Mocker.GetMock <IEpisodeService>()
     .Verify(v => v.UpdateEpisodes(It.Is <List <Episode> >(l => l.Where(predicate).All(e => !e.Monitored))));
 }
 private void GivenFreeSpace(long?size)
 {
     Mocker.GetMock <IDiskProvider>()
     .Setup(s => s.GetAvailableSpace(It.IsAny <string>()))
     .Returns(size);
 }
 private void VerifySeasonNotMonitored(Func <Season, bool> predicate)
 {
     Mocker.GetMock <ISeriesService>()
     .Verify(v => v.UpdateSeries(It.Is <Series>(s => s.Seasons.Where(predicate).All(n => !n.Monitored)), It.IsAny <bool>(), It.IsAny <bool>()));
 }
 protected void GivenFailedDownload()
 {
     Mocker.GetMock <ITransmissionProxy>()
     .Setup(s => s.AddTorrentFromUrl(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <TransmissionSettings>()))
     .Throws <InvalidOperationException>();
 }
Exemple #28
0
 private void WithFailedHardlink()
 {
     Mocker.GetMock <IDiskProvider>()
     .Setup(v => v.TryCreateHardLink(It.IsAny <string>(), It.IsAny <string>()))
     .Returns(false);
 }
Exemple #29
0
 protected void WithTempAsAppPath()
 {
     Mocker.GetMock <EnvironmentProvider>()
     .SetupGet(c => c.ApplicationPath)
     .Returns(VirtualPath);
 }
 private void VerifyBackOff()
 {
     Mocker.GetMock <IIndexerStatusService>()
     .Verify(v => v.RecordFailure(It.IsAny <int>(), It.IsAny <TimeSpan>()), Times.Once());
 }
Exemple #31
0
        public void WhenNuspecDoesNotHaveMatchingProject_ShouldThrowInvalidOperation()
        {
            //Arrange
            var mocker = new Mocker<Publisher>();

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.GetDirectory(It.Is<string>(s => s == _defaultSolutionFile)))
                .Returns(_defaultSolutionDir);

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.GetDirectory(It.Is<string>(s => s == _defaultProject1Path)))
                .Returns(_defaultProject1Dir);

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.FindFiles(
                    It.Is<string>(s => s == _defaultSolutionDir),
                    It.Is<string>(s => s == _defaultNuspecPattern),
                    It.Is<bool>(b => b == true))
                ).Returns(new string[] { _defaultProject1Path });

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.FindFiles(
                    It.Is<string>(s => s == _defaultProject1Dir),
                    It.Is<string>(s => s == "*.csproj"),
                    It.Is<bool>(b => b == false))
                ).Returns(new string[] { });

            mocker.SetBehavior<ILog>(MockBehavior.Loose);

            var publisher = mocker.Create() as IPublisher;

            //Act
            var exception = ExceptionTest.Catch(() => publisher.PublishPackages(_defaultSolutionFile, _defaultNuspecPattern, "Release", false));

            //Assert
            mocker.VerifyAll();
            Assert.AreEqual(typeof(InvalidOperationException), exception.GetType());
        }
Exemple #32
0
 private TaskProxy CreateSut() => Mocker.CreateInstance <TaskProxy>();
 private void GivenUpgradeForExistingFile()
 {
     Mocker.GetMock <IUpgradableSpecification>()
     .Setup(s => s.IsUpgradable(It.IsAny <Profile>(), It.IsAny <QualityModel>(), It.IsAny <List <CustomFormat> >(), It.IsAny <QualityModel>(), It.IsAny <List <CustomFormat> >()))
     .Returns(true);
 }
 private void GivenFolderExists(string folder)
 {
     Mocker.GetMock <IDiskProvider>()
     .Setup(x => x.FolderExists(folder))
     .Returns(true);
 }
Exemple #35
0
        public void When_Should()
        {
            //Arrange
            var projectFile = "Project.csproj";
            var nuspecFile = "Project.nuspec";
            var nuGetFile = "Project.nupkg";
            var mocker = new Mocker<PackageFactory>();

            mocker.GetMock<IFileSystem>()
                .Setup(f => f.OpenRead(It.Is<string>(s => s == projectFile)))
                .Returns(File.OpenRead(Path.Combine(Directory.GetCurrentDirectory(), @"SampleProjectFile.xml")));

            mocker.GetMock<IFileSystem>()
                .Setup(f => f.ChangeFileExtension(It.Is<string>(s => s == projectFile), It.Is<string>(s => s == "nupkg")))
                .Returns(nuGetFile);

            mocker.GetMock<IFileSystem>()
                .Setup(f => f.GetDirectory(It.Is<string>(s => s == projectFile)))
                .Returns(string.Empty);

            mocker.GetMock<IFileSystem>()
                .Setup(f => f.CombinePaths(It.IsAny<string>(),  It.Is<string>(s => s == "packages.config")))
                .Returns("packages.config");

            mocker.GetMock<IFileSystem>()
                .Setup(f => f.CombinePaths(It.Is<string>(s => s == @"bin\Release"), It.Is<string>(s => s == "Project.dll")))
                .Returns(@"bin\Release\Project.dll");

            mocker.GetMock<IFileSystem>()
                .Setup(f => f.FindFiles(It.Is<string>(s => s == @"bin\Release"), It.Is<string>(s => s == "*.dll"), It.IsAny<bool>()))
                .Returns(Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll").Select(s => Path.GetFileName(s)));

            mocker.GetMock<IFileSystem>()
                .Setup(f => f.OpenWrite(It.Is<string>(s => s == nuGetFile)))
                .Returns(new FileStream(nuGetFile, FileMode.Create, FileAccess.ReadWrite));

            var projectReaderMoq = new Mock<IVsProjectReader>(MockBehavior.Strict);
            projectReaderMoq
                .Setup(r => r.GetBinPath(It.Is<string>(s => s == "Release")))
                .Returns(@"bin\Release");
            projectReaderMoq
                .Setup(r => r.GetAssemblyName())
                .Returns("Project.dll");

            mocker.GetMock<IVsProjectReaderFactory>()
                .Setup(r => r.Create(It.Is<string>(s => s == projectFile)))
                .Returns(projectReaderMoq.Object);

            var assemblyReaderMoq = new Mock<IAssemblyReader>(MockBehavior.Strict);
            assemblyReaderMoq.Setup(r => r.GetCompany()).Returns("Run00");
            assemblyReaderMoq.Setup(r => r.GetCopyright()).Returns("2013");
            assemblyReaderMoq.Setup(r => r.GetDescription()).Returns("Blah Blah");
            assemblyReaderMoq.Setup(r => r.GetFileVersion()).Returns("1.0.0.0");
            assemblyReaderMoq.Setup(r => r.GetPackageId()).Returns("Run00.Product.Title");
            assemblyReaderMoq.Setup(r => r.GetPackageTitle()).Returns("Title for Run00.Product");
            assemblyReaderMoq.Setup(r => r.GetProduct()).Returns("Product");
            assemblyReaderMoq.Setup(r => r.GetTitle()).Returns("Title");

            mocker.GetMock<IAssemblyReaderFactory>()
                .Setup(f => f.Create(It.Is<string>(s => s == @"bin\Release\Project.dll")))
                .Returns(assemblyReaderMoq.Object);

            var packageFactory = mocker.Create() as IPackageFactory;

            //Act
            var result = packageFactory.CreateFromProject(nuspecFile, projectFile, "Release", true);

            //Assert
        }
        public void Setup()
        {
            _artist = Builder <Artist>
                      .CreateNew()
                      .With(s => s.Name     = "Linkin Park")
                      .With(s => s.Metadata = new ArtistMetadata {
                Disambiguation = "US Rock Band",
                Name           = "Linkin Park"
            })
                      .Build();

            _medium = Builder <Medium>
                      .CreateNew()
                      .With(m => m.Number = 3)
                      .Build();

            _release = Builder <AlbumRelease>
                       .CreateNew()
                       .With(s => s.Media = new List <Medium> {
                _medium
            })
                       .With(s => s.Monitored = true)
                       .Build();

            _album = Builder <Album>
                     .CreateNew()
                     .With(s => s.Title          = "Hybrid Theory")
                     .With(s => s.AlbumType      = "Album")
                     .With(s => s.Disambiguation = "The Best Album")
                     .Build();


            _namingConfig = NamingConfig.Default;
            _namingConfig.RenameTracks = true;


            Mocker.GetMock <INamingConfigService>()
            .Setup(c => c.GetConfig()).Returns(_namingConfig);

            _track1 = Builder <Track> .CreateNew()
                      .With(e => e.Title = "City Sushi")
                      .With(e => e.AbsoluteTrackNumber = 6)
                      .With(e => e.AlbumRelease        = _release)
                      .With(e => e.MediumNumber        = _medium.Number)
                      .Build();

            _trackFile = Builder <TrackFile> .CreateNew()
                         .With(e => e.Quality      = new QualityModel(Quality.MP3_256))
                         .With(e => e.ReleaseGroup = "GamearrTest")
                         .With(e => e.MediaInfo    = new Parser.Model.MediaInfoModel {
                AudioBitrate    = 320,
                AudioBits       = 16,
                AudioChannels   = 2,
                AudioFormat     = "Flac Audio",
                AudioSampleRate = 44100
            }).Build();

            Mocker.GetMock <IQualityDefinitionService>()
            .Setup(v => v.Get(Moq.It.IsAny <Quality>()))
            .Returns <Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
        }
Exemple #37
0
        public void WhenAllSolutionDataExists_ShouldPublishPackagesForEachNuspec()
        {
            //Arrange
            var mocker = new Mocker<Publisher>();

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.GetDirectory(It.Is<string>(s => s == _defaultSolutionFile)))
                .Returns(_defaultSolutionDir);

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.GetDirectory(It.Is<string>(s => s == _defaultNuspec1Path)))
                .Returns(_defaultProject1Dir);

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.GetDirectory(It.Is<string>(s => s == _defaultNuspec2Path)))
                .Returns(_defaultProject2Dir);

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.FindFiles(
                    It.Is<string>(s => s == _defaultSolutionDir),
                    It.Is<string>(s => s == _defaultNuspecPattern),
                    It.Is<bool>(b => b == true))
                ).Returns(new string[] { _defaultNuspec1Path, _defaultNuspec2Path });

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.FindFiles(
                    It.Is<string>(s => s == _defaultProject1Dir),
                    It.Is<string>(s => s == "*.csproj"),
                    It.Is<bool>(b => b == false))
                ).Returns(new string[] { _defaultProject1Path });

            mocker.GetMock<Run00.FileSystem.IFileSystem>()
                .Setup(f => f.FindFiles(
                    It.Is<string>(s => s == _defaultProject2Dir),
                    It.Is<string>(s => s == "*.csproj"),
                    It.Is<bool>(b => b == false))
                ).Returns(new string[] { _defaultProject2Path });

            var project1Package = new Mock<IPackage>();
            mocker.GetMock<IPackageFactory>()
                .Setup(f => f.CreateFromProject(
                    It.Is<string>(s => s == _defaultNuspec1Path),
                    It.Is<string>(s => s == _defaultProject1Path),
                    It.IsAny<string>(),
                    It.IsAny<bool>())
                ).Returns(project1Package.Object);

            var project2Package = new Mock<IPackage>();
            mocker.GetMock<IPackageFactory>()
                .Setup(f => f.CreateFromProject(
                    It.Is<string>(s => s == _defaultNuspec2Path),
                    It.Is<string>(s => s == _defaultProject2Path),
                    It.IsAny<string>(),
                    It.IsAny<bool>())
                ).Returns(project2Package.Object);

            mocker.GetMock<INuGetServer>()
                .Setup(s => s.PushPackage(It.Is<IPackage>(p => p == project1Package.Object || p == project2Package.Object)));

            mocker.SetBehavior<ILog>(MockBehavior.Loose);

            var publisher = mocker.Create() as IPublisher;

            //Act
            publisher.PublishPackages(_defaultSolutionFile, _defaultNuspecPattern, "Release", false);

            //Assert
            mocker.VerifyAll();
        }
Exemple #38
0
 private void WithNonExistingFolder()
 {
     Mocker.GetMock <IDiskProvider>()
     .Setup(m => m.FolderExists(It.IsAny <string>()))
     .Returns(false);
 }
Exemple #39
0
 public void should_be_able_to_remove_root_dir()
 {
     Subject.Remove(1);
     Mocker.GetMock <IRootFolderRepository>().Verify(c => c.Delete(1), Times.Once());
 }
 private void GivenDocker()
 {
     Mocker.GetMock <IOsInfo>()
     .Setup(x => x.IsDocker)
     .Returns(true);
 }
Exemple #41
-1
        public void Should_Inject_Dependencies_Via_Constructor()
        {
            var mocker = new Mocker<ObjectUnderTest>();

            mocker.ObjectUnderTest.Dep1.Should().BeAssignableTo<IDependencyOne>();
            mocker.ObjectUnderTest.Dep2.Should().BeAssignableTo<IDependencyTwo>();
        }