Exemplo n.º 1
0
        public void AcceptSurrenderNoGoods()
        {
            combat.OfferSurrender();
            combat.AcceptSurrender();

            Assert.That(player2.Ship.GetGoods(), Has.Length(0), "Player 2 should not have picked up any goods");
        }
Exemplo n.º 2
0
        public void It_Returns_The_Reference_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var entity1 = new EntityImpl("T1");
            var entity2 = new EntityImpl("T2");
            var entity3 = new EntityImpl("T3");
            var rel1    = new ReferenceImpl {
                EntitySet = info.MappingSet.EntitySet
            };
            var rel2 = new ReferenceImpl {
                EntitySet = info.MappingSet.EntitySet
            };

            info.MappingSet.EntitySet.AddEntity(entity1);
            info.MappingSet.EntitySet.AddEntity(entity2);
            info.MappingSet.EntitySet.AddEntity(entity3);

            rel1.AddThisTo(entity1, entity2);
            rel2.AddThisTo(entity3, entity2);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(Reference));

            Assert.That(objects, Has.Length(2));
            Assert.That(objects.Contains(rel1));
            Assert.That(objects.Contains(rel2));
        }
Exemplo n.º 3
0
        public void It_Returns_The_One_MappingSet_Object()
        {
            ProviderInfo info = new ProviderInfo();
            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(EntitySet));

            Assert.That(objects, Has.Length(1));
            Assert.That(objects.ElementAt(0), Is.SameAs(info.MappingSet.EntitySet));
        }
Exemplo n.º 4
0
        public void GetPlayersToNotify4()
        {
            var mapName = "illinois";

            server.Galaxy.Players[0].ReminderEvent = ReminderEvent.None;
            server.Galaxy.Players[1].ReminderLevel = ReminderLevel.AllBattles;
            var players = server.GetPlayersToNotify(springieAuth, mapName, ReminderEvent.OnBattleStarted);

            Assert.That(players, Has.Length(0));
        }
Exemplo n.º 5
0
        public void GetPlayersToNotify3()
        {
            var mapName = "illinois";

            server.Galaxy.Players[0].ReminderEvent = ReminderEvent.None;
            server.Galaxy.Players[1].ReminderLevel = ReminderLevel.AllBattles;
            var players = server.GetPlayersToNotify(springieAuth, mapName, ReminderEvent.OnBattlePreparing);

            Assert.That(players, Has.Member("John"));
            Assert.That(players, Has.Length(1));
        }
Exemplo n.º 6
0
        public void GetPlayersToNotify5()
        {
            var mapName = "delaware";

            server.Galaxy.Players[3].ReminderEvent = ReminderEvent.OnBattleStarted | ReminderEvent.OnBattlePreparing |
                                                     ReminderEvent.OnBattleEnded;
            server.Galaxy.Players[3].ReminderLevel = ReminderLevel.AllBattles;
            var players = server.GetPlayersToNotify(springieAuth, mapName, ReminderEvent.OnBattleStarted);

            Assert.That(players, Has.Member("Sarah"));
            Assert.That(players, Has.Length(1));
        }
Exemplo n.º 7
0
        public void GetPlayersToNotify()
        {
            var mapName = "illinois";

            server.Galaxy.Players[0].ReminderLevel           = ReminderLevel.MyPlanet;
            server.Galaxy.Players[0].ReminderEvent           = ReminderEvent.OnBattlePreparing;
            server.Galaxy.Players[0].ReminderRoundInitiative = ReminderRoundInitiative.Offense |
                                                               ReminderRoundInitiative.Defense;
            var players = server.GetPlayersToNotify(springieAuth, mapName, ReminderEvent.OnBattlePreparing);

            Assert.That(players, Has.Member("Barack"));
            Assert.That(players, Has.Length(1));
        }
Exemplo n.º 8
0
        public void It_Returns_The_Entity_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var entity = new EntityImpl();

            info.MappingSet.EntitySet.AddEntity(entity);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(Entity));

            Assert.That(objects, Has.Length(1));
            Assert.That(objects.ElementAt(0), Is.SameAs(entity));
        }
Exemplo n.º 9
0
        public void It_Returns_The_ITable_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var table = new Table();

            info.MappingSet.Database.AddTable(table);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(ITable));

            Assert.That(objects, Has.Length(1));
            Assert.That(objects.ElementAt(0), Is.SameAs(table));
        }
Exemplo n.º 10
0
        public void GetPlayersToNotify6()
        {
            var mapName = "alaska";

            server.Galaxy.Players[3].ReminderEvent = ReminderEvent.OnBattleStarted | ReminderEvent.OnBattlePreparing |
                                                     ReminderEvent.OnBattleEnded;
            server.Galaxy.Players[1].ReminderLevel = ReminderLevel.AllBattles;
            var players = server.GetPlayersToNotify(springieAuth, mapName, ReminderEvent.OnBattlePreparing);

            Console.WriteLine(players.Contains("Sarah"));
            Assert.That(players, Has.Member("John"));
            Assert.That(players, Has.Member("Sarah"));
            Assert.That(players, Has.Length(2));
        }
Exemplo n.º 11
0
        public void PropertyTests()
        {
            string[] array = new string[] { "abc", "bca", "xyz" };

            // Helper syntax
            Assert.That("Hello", Has.Property("Length", 5));
            Assert.That("Hello", Has.Length(5));
            Assert.That(array, Has.All.Property("Length", 3));
            Assert.That(array, Has.All.Length(3));

            // Inherited syntax
            Expect("Hello", Property("Length", 5));
            Expect("Hello", Length(5));
            Expect(array, All.Property("Length", 3));
            Expect(array, All.Length(3));
        }
Exemplo n.º 12
0
        public void It_Returns_The_Mapping_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var mapping1 = new MappingImpl();
            var mapping2 = new MappingImpl();

            info.MappingSet.AddMapping(mapping1);
            info.MappingSet.AddMapping(mapping2);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(Mapping));

            Assert.That(objects, Has.Length(2));
            Assert.That(objects.Contains(mapping1), "Missing mapping1");
            Assert.That(objects.Contains(mapping2), "Missing mapping2");
        }
Exemplo n.º 13
0
        public void It_Returns_The_EntityKey_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var entity1 = new EntityImpl();
            var entity2 = new EntityImpl();

            info.MappingSet.EntitySet.AddEntity(entity1);
            info.MappingSet.EntitySet.AddEntity(entity2);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(EntityKey));

            Assert.That(objects, Has.Length(2));
            Assert.That(objects.Contains(entity1.Key));
            Assert.That(objects.Contains(entity2.Key));
        }
Exemplo n.º 14
0
        public void It_Returns_The_ITable_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var table  = new Table("T1");
            var table2 = new Table("T2");

            info.MappingSet.Database.AddTable(table);
            info.MappingSet.Database.AddTable(table2);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(ITable));

            Assert.That(objects, Has.Length(2));
            Assert.That(objects.Contains(table));
            Assert.That(objects.Contains(table2));
        }
Exemplo n.º 15
0
        void RunTypingTest()
        {
            var openFile = filesToOpen.LastOrDefault();

            if (openFile == null)
            {
                return;
            }

            // Open files.
            WorkbenchExtensions.OpenFiles(filesToOpen);

            // Wait for the text area to be available.
            var area = TestService.Session.WaitForElement(IdeQuery.TextAreaForFile(openFile), 10000);

            Assert.That(area, Has.Length(1));

            UserInterfaceTests.Ide.WaitForIdeIdle();

            // Go to the start of the document.
            TextEditor.MoveCaretToDocumentStart();
            UserInterfaceTests.Ide.WaitForIdeIdle();

            if (!TextToEnter.Any())
            {
                return;
            }

            // Make some changes to the active file and then remove the changes.
            TextEditor.EnterText(TextToEnter);
            UserInterfaceTests.Ide.WaitForIdeIdle();

            WorkbenchExtensions.SaveFile();
            UserInterfaceTests.Ide.WaitForIdeIdle();

            TextEditor.DeleteToLineStart();
            UserInterfaceTests.Ide.WaitForIdeIdle();

            WorkbenchExtensions.SaveFile();
            UserInterfaceTests.Ide.WaitForIdeIdle();
        }
Exemplo n.º 16
0
        public void It_Returns_The_IColumn_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var table1  = new Table();
            var column1 = new Column("Col1");

            table1.AddColumn(column1);
            var table2  = new Table();
            var column2 = new Column("Col2");

            table2.AddColumn(column2);
            info.MappingSet.Database.AddTable(table1);
            info.MappingSet.Database.AddTable(table2);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(IColumn));

            Assert.That(objects, Has.Length(2));
            Assert.That(objects.Contains(column1));
            Assert.That(objects.Contains(column2));
        }
Exemplo n.º 17
0
        public void It_Returns_The_IKey_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var table1 = new Table();
            var index1 = new Key("1");

            table1.AddKey(index1);
            var table2 = new Table();
            var index2 = new Key("2");

            table2.AddKey(index2);
            info.MappingSet.Database.AddTable(table1);
            info.MappingSet.Database.AddTable(table2);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(IKey));

            Assert.That(objects, Has.Length(2));
            Assert.That(objects.Contains(index1));
            Assert.That(objects.Contains(index2));
        }
Exemplo n.º 18
0
        public void It_Returns_The_Relationship_Objects()
        {
            ProviderInfo info = new ProviderInfo();

            var entity1 = new Table("T1");
            var entity2 = new Table("T2");
            var entity3 = new Table("T3");
            var rel1    = new RelationshipImpl();
            var rel2    = new RelationshipImpl();

            info.MappingSet.Database.AddEntity(entity1);
            info.MappingSet.Database.AddEntity(entity2);
            info.MappingSet.Database.AddEntity(entity3);

            rel1.AddThisTo(entity1, entity2);
            rel2.AddThisTo(entity3, entity2);

            IEnumerable <IScriptBaseObject> objects = info.GetAllObjectsOfType(typeof(Relationship));

            Assert.That(objects, Has.Length(2));
            Assert.That(objects.Contains(rel1));
            Assert.That(objects.Contains(rel2));
        }
 public void Check_Photo()
 {
     Assert.That(employee.Photo, Is.Not.Null);
     Assert.That(employee.Photo, Has.Length(21626));             // Can't check much more than this.
 }
Exemplo n.º 20
0
        public void PropertyTests()
        {
            string[]  array  = { "abc", "bca", "xyz", "qrs" };
            string[]  array2 = { "a", "ab", "abc" };
            ArrayList list   = new ArrayList(array);

            // Not available using the classic syntax

            // Helper syntax
            Ensure.That(list, Has.Property("Count"));
            Ensure.That(list, Has.No.Property("Length"));

            Ensure.That("Hello", Has.Property("Length", 5));
            Ensure.That("Hello", Has.Length(5));
            Ensure.That("Hello", Has.Property("Length").EqualTo(5));
            Ensure.That("Hello", Has.Property("Length").GreaterThan(3));

            Ensure.That(array, Has.Property("Length", 4));
            Ensure.That(array, Has.Length(4));
            Ensure.That(array, Has.Property("Length").LessThan(10));

            Ensure.That(array, Has.All.Property("Length", 3));
            Ensure.That(array, Has.All.Length(3));
            Ensure.That(array, Is.All.Length(3));
            Ensure.That(array, Has.All.Property("Length").EqualTo(3));
            Ensure.That(array, Is.All.Property("Length").EqualTo(3));

            Ensure.That(array2, Has.Some.Property("Length", 2));
            Ensure.That(array2, Has.Some.Length(2));
            Ensure.That(array2, Has.Some.Property("Length").GreaterThan(2));

            Ensure.That(array2, Is.Not.Property("Length", 4));
            Ensure.That(array2, Is.Not.Length(4));
            Ensure.That(array2, Has.No.Property("Length").GreaterThan(3));

            Ensure.That(List.Map(array2).Property("Length"), Is.EqualTo(new int[] { 1, 2, 3 }));
            Ensure.That(List.Map(array2).Property("Length"), Is.EquivalentTo(new int[] { 3, 2, 1 }));
            Ensure.That(List.Map(array2).Property("Length"), Is.SubsetOf(new int[] { 1, 2, 3, 4, 5 }));
            Ensure.That(List.Map(array2).Property("Length"), Is.Unique);

            Ensure.That(list, Has.Count(4));

            // Inherited syntax
            EnsuranceHelper.Expect(list, Property("Count"));
            EnsuranceHelper.Expect(list, Not.Property("Nada"));

            EnsuranceHelper.Expect("Hello", Property("Length", 5));
            EnsuranceHelper.Expect("Hello", Length(5));
            EnsuranceHelper.Expect("Hello", Property("Length").EqualTo(5));
            EnsuranceHelper.Expect("Hello", Property("Length").GreaterThan(0));

            EnsuranceHelper.Expect(array, Property("Length", 4));
            EnsuranceHelper.Expect(array, Length(4));
            EnsuranceHelper.Expect(array, Property("Length").LessThan(10));

            EnsuranceHelper.Expect(array, All.Property("Length", 3));
            EnsuranceHelper.Expect(array, All.Length(3));
            EnsuranceHelper.Expect(array, All.Property("Length").EqualTo(3));

            EnsuranceHelper.Expect(array2, Some.Property("Length", 2));
            EnsuranceHelper.Expect(array2, Some.Length(2));
            EnsuranceHelper.Expect(array2, Some.Property("Length").GreaterThan(2));

            EnsuranceHelper.Expect(array2, None.Property("Length", 4));
            EnsuranceHelper.Expect(array2, None.Length(4));
            EnsuranceHelper.Expect(array2, None.Property("Length").GreaterThan(3));

            EnsuranceHelper.Expect(new ListMapper(array2).Property("Length"), EqualTo(new int[] { 1, 2, 3 }));
            EnsuranceHelper.Expect(new ListMapper(array2).Property("Length"), EquivalentTo(new int[] { 3, 2, 1 }));
            EnsuranceHelper.Expect(new ListMapper(array2).Property("Length"), SubsetOf(new int[] { 1, 2, 3, 4, 5 }));
            EnsuranceHelper.Expect(new ListMapper(array2).Property("Length"), Unique);

            EnsuranceHelper.Expect(list, Count(4));
        }
 public void Check_Picture()
 {
     Assert.That(category.Picture, Is.Not.Null);
     Assert.That(category.Picture, Has.Length(10746));
 }