public void TestConstructor()
        {
            var indexer = new TestWebIndexer();
            var caps    = indexer.TorznabCaps;

            Assert.True(caps.SearchAvailable);
            Assert.IsEmpty(caps.TvSearchParams);
            Assert.False(caps.TvSearchAvailable);
            Assert.False(caps.TvSearchSeasonAvailable);
            Assert.False(caps.TvSearchEpAvailable);
            Assert.False(caps.TvSearchImdbAvailable);
            Assert.False(caps.TvSearchTvdbAvailable);
            Assert.False(caps.TvSearchTvRageAvailable);
            Assert.IsEmpty(caps.MovieSearchParams);
            Assert.False(caps.MovieSearchAvailable);
            Assert.False(caps.MovieSearchImdbAvailable);
            Assert.False(caps.MovieSearchTmdbAvailable);
            Assert.IsEmpty(caps.MusicSearchParams);
            Assert.False(caps.MusicSearchAvailable);
            Assert.False(caps.MusicSearchAlbumAvailable);
            Assert.False(caps.MusicSearchArtistAvailable);
            Assert.False(caps.MusicSearchLabelAvailable);
            Assert.False(caps.MusicSearchYearAvailable);
            Assert.IsEmpty(caps.BookSearchParams);
            Assert.False(caps.BookSearchAvailable);
            Assert.False(caps.BookSearchTitleAvailable);
            Assert.False(caps.BookSearchAuthorAvailable);
            Assert.AreEqual(0, caps.Categories.GetTorznabCategoryTree().Count);
        }
        public void TestConstructors()
        {
            var torznabCaps = new TorznabCapabilities();

            Assert.True(torznabCaps.SearchAvailable);

            Assert.IsEmpty(torznabCaps.TvSearchParams);
            Assert.False(torznabCaps.TvSearchAvailable);
            Assert.False(torznabCaps.TvSearchSeasonAvailable);
            Assert.False(torznabCaps.TvSearchEpAvailable);
            Assert.False(torznabCaps.TvSearchImdbAvailable);
            Assert.False(torznabCaps.TvSearchTvdbAvailable);
            Assert.False(torznabCaps.TvSearchTvRageAvailable);

            Assert.IsEmpty(torznabCaps.MovieSearchParams);
            Assert.False(torznabCaps.MovieSearchAvailable);
            Assert.False(torznabCaps.MovieSearchImdbAvailable);
            Assert.False(torznabCaps.MovieSearchTmdbAvailable);

            Assert.IsEmpty(torznabCaps.MusicSearchParams);
            Assert.False(torznabCaps.MusicSearchAvailable);
            Assert.False(torznabCaps.MusicSearchAlbumAvailable);
            Assert.False(torznabCaps.MusicSearchArtistAvailable);
            Assert.False(torznabCaps.MusicSearchLabelAvailable);
            Assert.False(torznabCaps.MusicSearchYearAvailable);

            Assert.IsEmpty(torznabCaps.BookSearchParams);
            Assert.False(torznabCaps.BookSearchAvailable);
            Assert.False(torznabCaps.BookSearchTitleAvailable);
            Assert.False(torznabCaps.BookSearchAuthorAvailable);

            Assert.IsEmpty(torznabCaps.Categories.GetTorznabCategoryTree());
            Assert.IsEmpty(torznabCaps.Categories.GetTrackerCategories());
        }
Ejemplo n.º 3
0
        public void TestConstructors()
        {
            // TODO: initialize MusicSearchAvailable
            var torznabCaps = new TorznabCapabilities();

            Assert.True(torznabCaps.SearchAvailable);

            Assert.IsEmpty(torznabCaps.TvSearchParams);
            Assert.False(torznabCaps.TvSearchAvailable);
            Assert.False(torznabCaps.TvSearchSeasonAvailable);
            Assert.False(torznabCaps.TvSearchEpAvailable);
            Assert.False(torznabCaps.TvSearchImdbAvailable);
            Assert.False(torznabCaps.TvSearchTvdbAvailable);
            Assert.False(torznabCaps.TvSearchTvRageAvailable);

            Assert.IsEmpty(torznabCaps.MovieSearchParams);
            Assert.False(torznabCaps.MovieSearchAvailable);
            Assert.False(torznabCaps.MovieSearchImdbAvailable);
            Assert.False(torznabCaps.MovieSearchTmdbAvailable);

            Assert.IsEmpty(torznabCaps.SupportedMusicSearchParamsList);
            Assert.False(torznabCaps.MusicSearchAvailable); // init

            Assert.False(torznabCaps.BookSearchAvailable);

            Assert.IsEmpty(torznabCaps.Categories);
        }
Ejemplo n.º 4
0
        public void TestAddingAlreadyPresentRecordingDeviceToSelected()
        {
            var configurationMoq = new Mock <ISoundSwitchConfiguration> {
                Name = "Configuration mock"
            };
            var audioMoqI = new Mock <IAudioDevice> {
                Name = "first audio dev"
            };

            audioMoqI.SetupGet(a => a.Id).Returns("Speakers (Test device)");
            audioMoqI.SetupGet(a => a.Type).Returns(AudioDeviceType.Recording);

            //Setup
            configurationMoq.Setup(c => c.SelectedRecordingDeviceListId)
            .Returns(new HashSet <string> {
                "Speakers (Test device)"
            });
            TestHelpers.SetConfigurationMoq(configurationMoq);

            //Action
            var eventCalled = false;

            AppModel.Instance.SelectedDeviceChanged += (sender, changed) => eventCalled = true;
            Assert.False(AppModel.Instance.SelectDevice(audioMoqI.Object));

            //Asserts
            configurationMoq.VerifyGet(c => c.SelectedRecordingDeviceListId);
            audioMoqI.VerifyGet(a => a.Id);
            audioMoqI.VerifyGet(a => a.Type);
            Assert.That(configurationMoq.Object.SelectedRecordingDeviceListId.Count == 1);
            Assert.That(!eventCalled, "SelectedDeviceChanged called");
        }
Ejemplo n.º 5
0
        public void TestTorznabConcat()
        {
            var torznabCaps1 = new TorznabCapabilities();
            var torznabCaps2 = new TorznabCapabilities();
            var res          = TorznabCapabilities.Concat(torznabCaps1, torznabCaps2);

            Assert.True(res.SearchAvailable);
            Assert.IsEmpty(res.TvSearchParams);
            Assert.IsEmpty(res.MovieSearchParams);
            Assert.IsEmpty(res.MusicSearchParams);
            Assert.IsEmpty(res.BookSearchParams);
            Assert.IsEmpty(res.Categories);

            torznabCaps1 = new TorznabCapabilities
            {
                SearchAvailable = false,
                TvSearchParams  = new List <TvSearchParam> {
                    TvSearchParam.Q
                },
                MovieSearchParams = new List <MovieSearchParam> {
                    MovieSearchParam.Q
                },
                MusicSearchParams = new List <MusicSearchParam> {
                    MusicSearchParam.Q
                },
                BookSearchParams = new List <BookSearchParam> {
                    BookSearchParam.Q
                },
                Categories = new List <TorznabCategory> {
                    TorznabCatType.Movies, new TorznabCategory(100001, "CustomCat1")
                }
            };
            torznabCaps2 = new TorznabCapabilities
            {
                SearchAvailable = false,
                TvSearchParams  = new List <TvSearchParam> {
                    TvSearchParam.Season
                },
                MovieSearchParams = new List <MovieSearchParam> {
                    MovieSearchParam.ImdbId
                },
                MusicSearchParams = new List <MusicSearchParam> {
                    MusicSearchParam.Artist
                },
                BookSearchParams = new List <BookSearchParam> {
                    BookSearchParam.Title
                },
                Categories = new List <TorznabCategory> {
                    TorznabCatType.TVAnime, new TorznabCategory(100002, "CustomCat2")
                }
            };
            res = TorznabCapabilities.Concat(torznabCaps1, torznabCaps2);

            Assert.False(res.SearchAvailable);
            Assert.True(res.TvSearchParams.Count == 2);
            Assert.True(res.MovieSearchParams.Count == 2);
            Assert.True(res.MusicSearchParams.Count == 2);
            Assert.True(res.BookSearchParams.Count == 2);
            Assert.True(res.Categories.Count == 3); // only CustomCat2 is removed
        }
Ejemplo n.º 6
0
        public void Init_StartPositionIsOutsideBounds_InitReturnsFalse(string startPosition)
        {
            var bounds = new Coordinates(5, 4);

            var result = _robot.Init(bounds, startPosition);

            Assert.False(result);
        }
Ejemplo n.º 7
0
        public void VerifyIsValidFileNameWhenCalledChangesWasLastFileNameValid()
        {
            var analyzer = new TheArtOfUnitTesting.LogAnalyzer();

            analyzer.IsValidLogFileName("badname.foo");

            Assert.False(analyzer.WasLastFileNameValid);
        }
Ejemplo n.º 8
0
        public async Task TestMvcMusicStore()
        {
            string solutionPath = Directory.EnumerateFiles(tempDir, "MvcMusicStore.sln", SearchOption.AllDirectories).FirstOrDefault();

            FileAssert.Exists(solutionPath);

            AnalyzerConfiguration configuration = new AnalyzerConfiguration(LanguageOptions.CSharp)
            {
                ExportSettings =
                {
                    GenerateJsonOutput = false,
                    OutputPath         = @"/tmp/UnitTests"
                },

                MetaDataSettings =
                {
                    LiteralExpressions = true,
                    MethodInvocations  = true,
                    Annotations        = true,
                    DeclarationNodes   = true,
                    LocationData       = false,
                    ReferenceData      = true,
                    LoadBuildData      = true
                }
            };
            CodeAnalyzer analyzer = CodeAnalyzerFactory.GetAnalyzer(configuration, NullLogger.Instance);

            using var result = (await analyzer.AnalyzeSolution(solutionPath)).FirstOrDefault();
            Assert.True(result != null);
            Assert.False(result.ProjectBuildResult.IsSyntaxAnalysis);

            Assert.AreEqual(28, result.ProjectResult.SourceFiles.Count);

            //Project has 16 nuget references and 19 framework/dll references:
            Assert.AreEqual(29, result.ProjectResult.ExternalReferences.NugetReferences.Count);
            Assert.AreEqual(24, result.ProjectResult.ExternalReferences.SdkReferences.Count);

            var homeController = result.ProjectResult.SourceFileResults.Where(f => f.FilePath.EndsWith("HomeController.cs")).FirstOrDefault();

            Assert.NotNull(homeController);

            var classDeclarations = homeController.Children.OfType <Codelyzer.Analysis.Model.NamespaceDeclaration>().FirstOrDefault();

            Assert.Greater(classDeclarations.Children.Count, 0);

            var classDeclaration = homeController.Children.OfType <Codelyzer.Analysis.Model.NamespaceDeclaration>().FirstOrDefault().Children[0];

            Assert.NotNull(classDeclaration);

            var declarationNodes   = classDeclaration.Children.OfType <Codelyzer.Analysis.Model.DeclarationNode>();
            var methodDeclarations = classDeclaration.Children.OfType <Model.MethodDeclaration>();

            //HouseController has 3 identifiers declared within the class declaration:
            Assert.AreEqual(4, declarationNodes.Count());

            //It has 2 method declarations
            Assert.AreEqual(2, methodDeclarations.Count());
        }
Ejemplo n.º 9
0
        public void Execute__EndPositionIsOutofBounds_ExecuteMethodReturnsFalse(string strStartPos, string strInstructions)
        {
            var bounds = new Coordinates(1, 2);

            _robot.Init(bounds, strStartPos);
            var result = _robot.ParseAndExecuteInstructions(strInstructions);

            Assert.False(result);
        }
Ejemplo n.º 10
0
        public void registrujSekretaricuBasicTest2()
        {
            Sekretarica sekretarica2 = new Sekretarica(korisnik2);

            centrala.registrujSekretaricu(sekretarica);
            Boolean result = centrala.registrujSekretaricu(sekretarica2);

            Assert.False(result);
        }
Ejemplo n.º 11
0
        public void TryRefillWithTooManyTokens()
        {
            _refillStrategy.AddTokens(Capacity);
            Assert.True(_bucket.TryConsume());

            _refillStrategy.AddTokens(long.MaxValue);
            Assert.True(_bucket.TryConsume(Capacity));
            Assert.False(_bucket.TryConsume(1));
        }
Ejemplo n.º 12
0
        public void CanAttackUnit_ArcherAttackFriend_False()
        {
            Player         Player         = new Player(1, "Игрок №1", null);
            Archer         Archer         = new Archer(Player, 10, 10);
            Archer         Target         = new Archer(Player, 11, 11);
            Map            Map            = CreateMap(units: new[] { Archer, Target });
            GameController GameController = new GameController(Map);

            Assert.False(GameController.CanAttackUnit(Archer, Target));
        }
Ejemplo n.º 13
0
        public void registrujSekretaricuIstiKorisnikTest()
        {
            korisnik2 = korisnik;
            Sekretarica sekretarica2 = new Sekretarica(korisnik2);

            centrala.registrujSekretaricu(sekretarica);
            Boolean result = centrala.registrujSekretaricu(sekretarica2);

            Assert.False(result);
        }
Ejemplo n.º 14
0
            public void ShouldFallOutsideGeoFence()
            {
                var deviceWithGeoFence = BufferedDeviceAtCCV();

                // (a point about half a mile away from CCV)
                var farLat        = "33.6961";
                var farLong       = "-112.2030";
                var aPointOutside = DbGeography.FromText(string.Format("POINT({0} {1})", farLong, farLat));     // NOTE: long, lat

                // This point should NOT intersect our buffered CCV location
                Assert.False(aPointOutside.Intersects(deviceWithGeoFence.Location.GeoFence));
            }
Ejemplo n.º 15
0
        public void GetDescriptionEnum()
        {
            var firstDescription  = MyEnum.First.GetDescription();
            var secondDescription = MyEnum.Second.GetDescription();
            var thirdDescription  = MyEnum.Third.GetDescription();
            var forthDescription  = MyEnum.Forth.GetDescription();

            Assert.True(string.IsNullOrEmpty(forthDescription));
            Assert.True(string.IsNullOrEmpty(firstDescription));
            Assert.False(string.IsNullOrEmpty(secondDescription));
            Assert.False(string.IsNullOrEmpty(thirdDescription));
        }
Ejemplo n.º 16
0
        public void Verify_Config_Not_Correct_IdentityMessages_From()
        {
            ConfigEntity.IdentityMessages[1].IdTypeValue = "juk_777@@mail.ru";
            List <ConfigEntity> configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };

            var configVerifier = new ConfigVerifier();
            var result         = configVerifier.Verify(configEntityList);

            Assert.False(result);
        }
Ejemplo n.º 17
0
        public void Verify_Config_Not_Correct_IdentityMessages_Body()
        {
            ConfigEntity.IdentityMessages[3].IdTypeValue = null;
            List <ConfigEntity> configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };

            var configVerifier = new ConfigVerifier();
            var result         = configVerifier.Verify(configEntityList);

            Assert.False(result);
        }
Ejemplo n.º 18
0
        public void Verify_Config_Not_Correct_MailActions_Forward()
        {
            ConfigEntity.MailActions[3].ActTypeValue = "juk_777@@mail.ru";
            List <ConfigEntity> configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };

            var configVerifier = new ConfigVerifier();
            var result         = configVerifier.Verify(configEntityList);

            Assert.False(result);
        }
Ejemplo n.º 19
0
        public void Verify_Config_Not_Correct_IdentityMessages_To()
        {
            ConfigEntity.IdentityMessages[0].IdTypeValue = "gus.guskovskij@@mail.ru";
            List <ConfigEntity> configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };

            var configVerifier = new ConfigVerifier();
            var result         = configVerifier.Verify(configEntityList);

            Assert.False(result);
        }
Ejemplo n.º 20
0
        public void Verify_Config_Not_Correct_MailActions_CopyTo()
        {
            ConfigEntity.MailActions[2].ActTypeValue = null;
            List <ConfigEntity> configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };

            var configVerifier = new ConfigVerifier();
            var result         = configVerifier.Verify(configEntityList);

            Assert.False(result);
        }
Ejemplo n.º 21
0
        public void Verify_Config_Not_Correct_Port()
        {
            ConfigEntity.Port = 0;
            List <ConfigEntity> configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };

            var configVerifier = new ConfigVerifier();
            var result         = configVerifier.Verify(configEntityList);

            Assert.False(result);
        }
Ejemplo n.º 22
0
        public void Verify_Config_Not_Correct_Mail()
        {
            ConfigEntity.Mail = "popp.yandex.ru";
            List <ConfigEntity> configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };

            var configVerifier = new ConfigVerifier();
            var result         = configVerifier.Verify(configEntityList);

            Assert.False(result);
        }
Ejemplo n.º 23
0
        public void CanMoveUnit_CatapultOnHorseman_False()
        {
            const int horsemanPositionX = 15;
            const int horsemanPositionY = 15;

            Player         Player         = new Player(1, "Игрок №1", null);
            Catapult       Catapult       = new Catapult(Player, 10, 10);
            Horseman       Horseman       = new Horseman(Player, horsemanPositionX, horsemanPositionY);
            Map            Map            = CreateMap(units: new object[] { Catapult, Horseman });
            GameController GameController = new GameController(Map);

            Assert.False(GameController.CanMoveUnit(Horseman, horsemanPositionX, horsemanPositionY));
        }
Ejemplo n.º 24
0
        public void CanMoveUnit_SwordsmanOnWater_False()
        {
            const int waterPositionX = 15;
            const int waterPositionY = 15;

            Player         Player         = new Player(1, "Игрок №1", null);
            Swordsman      Swordsman      = new Swordsman(Player, 10, 10);
            Water          Water          = new Water(waterPositionX, waterPositionY);
            Map            Map            = CreateMap(new[] { Water }, new[] { Swordsman });
            GameController GameController = new GameController(Map);

            Assert.False(GameController.CanMoveUnit(Swordsman, waterPositionX, waterPositionY));
        }
        public void TestSupportsCategories()
        {
            var tcc = CreateTestDataset();

            Assert.True(tcc.SupportsCategories(new [] { TorznabCatType.Movies.ID }));                             // parent cat
            Assert.True(tcc.SupportsCategories(new [] { TorznabCatType.MoviesSD.ID }));                           // child cat
            Assert.True(tcc.SupportsCategories(new [] { TorznabCatType.Movies.ID, TorznabCatType.MoviesSD.ID })); // parent & child
            Assert.True(tcc.SupportsCategories(new [] { 100044 }));                                               // custom cat
            // TODO: fix this
            //Assert.False(tcc.SupportsCategories(new []{ TorznabCatType.Movies3D.ID })); // not supported child cat
            Assert.False(tcc.SupportsCategories(new [] { 9999 })); // unknown cat
            Assert.False(tcc.SupportsCategories(new int[] {}));    // empty list
            Assert.False(tcc.SupportsCategories(null));            // null
        }
Ejemplo n.º 26
0
        public void ValidateNegativeEndDateIsEarlierThanStartDateTest()
        {
            var project = new Project()
            {
                ProjectName      = "Test",
                ProjectStartDate = DateTime.Now.AddDays(2),
                ProjectEndDate   = DateTime.Now.AddDays(1),
            };

            _projectValidator = new ProjectValidator();

            var result = _projectValidator.Validate(project);

            Assert.False(result);
        }
Ejemplo n.º 27
0
        public void When_nested_unit_of_work_does_not_commit_resource_then_outer_unit_of_work_closing_does_not_not_commit_it_either()
        {
            var committed = false;

            UnitOfWork <IDisposable> .Create = (_, setSubject) => setSubject(Disposable.Create(() => { }));
            UnitOfWork <IDisposable> .Commit = disposable => { committed = true; };

            using (var outer = new UnitOfWork <IDisposable>())
            {
                using (new UnitOfWork <IDisposable>())
                {
                }
                outer.VoteCommit();
            }
            Assert.False(committed);
        }
Ejemplo n.º 28
0
        public async Task TestAnalysis()
        {
            string projectPath = string.Concat(GetTstPath(Path.Combine(new string[] { "Projects", "CodelyzerDummy", "CodelyzerDummy" })), ".csproj");

            AnalyzerConfiguration configuration = new AnalyzerConfiguration(LanguageOptions.CSharp)
            {
                ExportSettings =
                {
                    GenerateJsonOutput = true,
                    OutputPath         = @"/tmp/UnitTests"
                },

                MetaDataSettings =
                {
                    LiteralExpressions = true,
                    MethodInvocations  = true,
                    Annotations        = true,
                    LambdaMethods      = true,
                    DeclarationNodes   = true,
                    LocationData       = true,
                    ReferenceData      = true,
                    LoadBuildData      = true
                }
            };
            CodeAnalyzer   analyzer = CodeAnalyzerFactory.GetAnalyzer(configuration, NullLogger.Instance);
            AnalyzerResult result   = await analyzer.AnalyzeProject(projectPath);

            Assert.False(result.ProjectBuildResult.IsSyntaxAnalysis);

            Assert.True(result != null);

            // Extract the subject node
            var testClassRootNode = result.ProjectResult.SourceFileResults
                                    .First(s => s.FileFullPath.EndsWith("Class2.cs"))
                                    as UstNode;

            // Nested class is found
            Assert.AreEqual(1, testClassRootNode.AllClasses().Count(c => c.Identifier == "NestedClass"));

            // Chained method is found
            Assert.AreEqual(1, testClassRootNode.AllInvocationExpressions().Count(c => c.MethodName == "ChainedMethod"));

            // Constructor is found
            Assert.AreEqual(1, testClassRootNode.AllConstructors().Count);
        }
Ejemplo n.º 29
0
        public void TestConstructor()
        {
            var indexer = new TestWebIndexer();

            var dto = new Indexer(indexer);

            Assert.AreEqual("test_id", dto.id);
            Assert.AreEqual("test_name", dto.name);
            Assert.AreEqual("test_description", dto.description);
            Assert.AreEqual("private", dto.type);
            Assert.False(dto.configured);
            Assert.AreEqual("https://test.link/", dto.site_link);
            Assert.AreEqual(2, dto.alternativesitelinks.ToList().Count);
            Assert.AreEqual("en-us", dto.language);
            Assert.AreEqual("", dto.last_error);
            Assert.False(dto.potatoenabled);
            Assert.AreEqual(0, dto.caps.ToList().Count);
        }
Ejemplo n.º 30
0
        public void TestContainsConsistency()
        {
            var q = new AlternativePriorityQueue <int, int>();

            addRandomItems(q, 150);

            var missingNode = new PriorityQueueNode <int, int>(14);
            var presentNode = new PriorityQueueNode <int, int>(14);

            q.Enqueue(presentNode, 75);

            Assert.True(q.Contains(presentNode));
            Assert.False(q.Contains(missingNode));

            q.Remove(presentNode);
            Assert.False(q.Contains(presentNode));
            CheckOrder(q);
        }