public async Task UpdateExperienceDiffsAsync_RequirePermissionsAsyncFails_ReturnsImmediately()
        {
            using var testContext = new TestContext();

            var mockError = new Mock <OperationError>("Mock Message");

            testContext.RequirePermissionsResult = OperationResult.FromError(mockError.Object);

            var uut = testContext.BuildUut();

            var experienceThresholds = TestArray.Unique <int>();

            var result = await uut.UpdateExperienceDiffsAsync(
                experienceThresholds,
                testContext.CancellationToken);

            result.IsFailure.ShouldBeTrue();
            result.Error.ShouldBeSameAs(mockError.Object);

            testContext.MockAuthorizationService.ShouldHaveReceived(x => x
                                                                    .RequirePermissionsAsync(
                                                                        It.Is <int[]>(y => (y != null) && (y.Length != 0)),
                                                                        testContext.CancellationToken));

            testContext.MockCharacterLevelsService.Invocations.ShouldBeEmpty();
        }
Ejemplo n.º 2
0
    private static int Main()
    {
#if !MULTIMODULE_BUILD
        TestLdstr.Run();
        TestException.Run();
        TestThreadStaticNotInitialized.Run();
        TestUntouchedThreadStaticInitialized.Run();
        TestPointers.Run();
        TestConstants.Run();
        TestArray.Run();
        TestMdArray.Run();
        TestSimpleObject.Run();
        TestFinalizableObject.Run();
        TestStoreIntoOtherStatic.Run();
        TestCctorCycle.Run();
        TestReferenceTypeAllocation.Run();
        TestReferenceTypeWithGCPointerAllocation.Run();
        TestRelationalOperators.Run();
        TestTryFinally.Run();
        TestTryCatch.Run();
        TestBadClass.Run();
        TestRefs.Run();
        TestDelegate.Run();
        TestInitFromOtherClass.Run();
        TestInitFromOtherClassDouble.Run();
        TestDelegateToOtherClass.Run();
#else
        Console.WriteLine("Preinitialization is disabled in multimodule builds for now. Skipping test.");
#endif

        return(100);
    }
Ejemplo n.º 3
0
        public async Task GetIdentitiesAsync_RequirePermissionsAsyncSucceeds_ReturnsGetCurrentIdentitiesAsync()
        {
            using var testContext = new TestContext();

            var identities = TestArray.Unique <CharacterGuildIdentityViewModel>();

            testContext.MockCharacterGuildsService
            .Setup(x => x.GetCurrentIdentitiesAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(identities);

            var uut = testContext.BuildUut();

            var result = await uut.GetIdentitiesAsync(
                testContext.CancellationToken);

            result.IsSuccess.ShouldBeTrue();
            result.Value.ShouldBeSameAs(identities);

            testContext.MockAuthorizationService.ShouldHaveReceived(x => x
                                                                    .RequirePermissionsAsync(
                                                                        It.Is <int[]>(y => (y != null) && (y.Length != 0)),
                                                                        testContext.CancellationToken));

            testContext.MockCharacterGuildsService
            .ShouldHaveReceived(x => x.GetCurrentIdentitiesAsync(testContext.CancellationToken));
        }
        public async Task GetDescriptionsAsync_RequirePermissionsAsyncSucceeds_ReturnsGetDescriptionsAsync()
        {
            using var testContext = new TestContext();

            testContext.MockAuthorizationService
            .Setup(x => x.RequirePermissionsAsync(It.IsAny <int[]>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(OperationResult.Success);

            var descriptions = TestArray.Unique <PermissionCategoryDescriptionViewModel>();

            testContext.MockPermissionsService
            .Setup(x => x.GetDescriptionsAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(descriptions);

            var uut = testContext.BuildUut();

            var result = await uut.GetDescriptionsAsync(
                testContext.CancellationToken);

            result.IsSuccess.ShouldBeTrue();
            result.Value.ShouldBeSameAs(descriptions);

            testContext.MockAuthorizationService.ShouldHaveReceived(x => x
                                                                    .RequirePermissionsAsync(
                                                                        It.Is <int[]>(y => (y != null) && (y.Length != 0)),
                                                                        testContext.CancellationToken));

            testContext.MockPermissionsService.ShouldHaveReceived(x => x
                                                                  .GetDescriptionsAsync(testContext.CancellationToken));
        }
Ejemplo n.º 5
0
        public void ShouldBeArrayOfType()
        {
            //Arrange
            TestArray subject = new TestArray();

            //Act
            object[] actual = subject;

            //Assert
            actual.Should().NotBeNull();
        }
        public void TestDeserializeArray()
        {
            string recordString = "values:[1,2,3,4,5]";

            var       rawRecord = Encoding.UTF8.GetBytes(recordString);
            ODocument document  = serializer.Deserialize(rawRecord, new ODocument());

            TypeMapper <TestArray> tm = TypeMapper <TestArray> .Instance;
            var t = new TestArray();

            tm.ToObject(document, t);

            Assert.NotNull(t.values);
            Assert.Equal(5, t.values.Length);
            Assert.Equal(3, t.values[2]);
        }
Ejemplo n.º 7
0
        public void TestDeserializeArray()
        {
            string recordString = "values:[1,2,3,4,5]";

            ODocument document = ODocument.Deserialize(recordString);


            TypeMapper <TestArray> tm = TypeMapper <TestArray> .Instance;
            var t = new TestArray();

            tm.ToObject(document, t);

            Assert.IsNotNull(t.values);
            Assert.AreEqual(5, t.values.Length);
            Assert.AreEqual(3, t.values[2]);
        }
Ejemplo n.º 8
0
        public IEnumerator ArrayAppend()
        {
            yield return(T().YieldWait()); async Task T()
            {
                var ta = new TestArray {
                    array1 = new List <object> {
                        11, "hey"
                    },
                    array2 = new List <object> {
                        44, "yo"
                    },
                    array3 = new List <object> {
                        66, "wow"
                    },
                };
                await TestDocument1.SetAsync <TestArray>(ta);

                await TestDocument1.ArrayAppendAsync("array2", new object[] { 55, 555 });

                var returned = (await TestDocument1.GetSnapshotAsync()).ConvertTo <TestArray>();

                Assert.That(returned.array1.Count, Is.EqualTo(2));
                Assert.That(returned.array2.Count, Is.EqualTo(4));
                Assert.That(returned.array3.Count, Is.EqualTo(2));

                Assert.That(returned.array2[0], Is.EqualTo(44));
                Assert.That(returned.array2[1], Is.EqualTo("yo"));
                Assert.That(returned.array2[2], Is.EqualTo(55));
                Assert.That(returned.array2[3], Is.EqualTo(555));

                await TestDocument1.ArrayAppendAsync("array2", new object[] { 666 });

                returned = (await TestDocument1.GetSnapshotAsync()).ConvertTo <TestArray>();

                Assert.That(returned.array2.Count, Is.EqualTo(5));
                Assert.That(returned.array2[3], Is.EqualTo(555));
                Assert.That(returned.array2[4], Is.EqualTo(666));

                await TestDocument1.ArrayAppendAsync("array2", new object[] { 666 });

                returned = (await TestDocument1.GetSnapshotAsync()).ConvertTo <TestArray>();

                Assert.That(returned.array2.Count, Is.EqualTo(5));
                Assert.That(returned.array2[3], Is.EqualTo(555));
                Assert.That(returned.array2[4], Is.EqualTo(666), "Array append is not able to add duplicate element (but array data structure itself can hold dup element.");
            }
        }
Ejemplo n.º 9
0
 public static void printTestArray(TestArray testArray)
 {
     String display = "";
     for (int i=0; i<testArray.codes.Length; i++){
         display += testArray.codes[i] + " ";
     }
     display += "\n";
     for (int i=0; i<testArray.values.Length; i++){
         display += testArray.values[i] + " ";
     }
     display += "\n";
     for (int i=0; i<testArray.codes.Length; i++){
         display += testArray.answers[i] + " ";
     }
     display += "\n";
     Console.Out.WriteLine(display);
 }
Ejemplo n.º 10
0
    /**
     * This method shows how easy is to serialize and de-serialize C# objects
     * to/from XML. The XML representation of the objects is a standard WOX representation.
     * For more information about the XML representation please visit:
     * http://woxserializer.sourceforge.net/
     */
    public static void main(String[] args)
    {
        TestArray testArray = new TestArray(new char[]{'e', 't', 'r', 'g', 'w'},
                                            new int[]{23, 56, 78, 33, 69},
                                            new bool[]{true, false, true, false, false});

        String filename = "C:\\TestPrimitiveArraysCSharp.xml";
        //print the object
        printTestArray(testArray);
        //object to standard XML
        Easy.save(testArray, filename);
        //load the object from the XML file
        TestArray newTestArray = (TestArray)Easy.load(filename);
        //print the new object - it is the same as before
        Console.Out.WriteLine(newTestArray);
        //printTestArray(newTestArray);
    }
Ejemplo n.º 11
0
    public void testCase1()
    {
        //測試array是否傳指標
        TestArray tArray = new TestArray();

        int[] a = tArray.getA();
        a[0] = 60;
        tArray.show();
        tArray.reset();
        tArray.show();

        Debug.Log("outside");
        foreach (int i in a)
        {
            Debug.Log(i);
        }
    }
        public void TestSerializeArray()
        {
            string recordString = "TestArray@values:[1,2,3,4,5]";

            ODocument document = ODocument.Deserialize(recordString);

            TypeMapper<TestArray> tm = TypeMapper<TestArray>.Instance;
            var t = new TestArray();
            tm.ToObject(document, t);

            Assert.IsNotNull(t.values);
            Assert.AreEqual(5, t.values.Length);
            Assert.AreEqual(3, t.values[2]);

            ODocument newODocument = ODocument.ToDocument(t);
            var serialized = newODocument.Serialize();
            Assert.AreEqual(recordString, serialized);
        }
Ejemplo n.º 13
0
        private void TestFSBArray()
        {
            int count = 10000;

            {
                Stopwatch       sw    = Stopwatch.StartNew();
                TestArray <int> array = new TestArray <int>(200);
                for (int i = 0; i < count; i++)
                {
                    array.Add(i);
                }
                for (int i = 0; i < count; i++)
                {
                    array.Insert(i, i * 10);
                }
                for (int i = 0; i < count; i++)
                {
                    array.RemoveAt(i);
                }
                _fsbArray = array;
                sw.Stop();
                Console.WriteLine("FSBArray: " + sw.ElapsedMilliseconds + "ms");
            }

            {
                Stopwatch  sw    = Stopwatch.StartNew();
                List <int> array = new List <int>(count);
                for (int i = 0; i < count; i++)
                {
                    array.Add(i);
                }
                for (int i = 0; i < count; i++)
                {
                    array.Insert(i, i * 10);
                }
                for (int i = 0; i < count; i++)
                {
                    array.RemoveAt(i);
                }
                _list = array;
                sw.Stop();
                Console.WriteLine("List: " + sw.ElapsedMilliseconds + "ms");
            }
        }
    /**
     * This method shows how easy is to serialize and de-serialize C# objects
     * to/from XML. The XML representation of the objects is a standard WOX representation.
     * For more information about the XML representation please visit:
     * http://woxserializer.sourceforge.net/
     */
    public static void main(String[] args)
    {
        TestArray testArray = new TestArray(new char[] { 'e', 't', 'r', 'g', 'w' },
                                            new int[] { 23, 56, 78, 33, 69 },
                                            new bool[] { true, false, true, false, false });

        String filename = "C:\\TestPrimitiveArraysCSharp.xml";

        //print the object
        printTestArray(testArray);
        //object to standard XML
        Easy.save(testArray, filename);
        //load the object from the XML file
        TestArray newTestArray = (TestArray)Easy.load(filename);

        //print the new object - it is the same as before
        Console.Out.WriteLine(newTestArray);
        //printTestArray(newTestArray);
    }
        public void TestSerializeArray()
        {
            string recordString = "TestArray@values:[1,2,3,4,5]";

            var rawRecord = Encoding.UTF8.GetBytes(recordString);
            ODocument document = serializer.Deserialize(rawRecord, new ODocument());

            TypeMapper<TestArray> tm = TypeMapper<TestArray>.Instance;
            var t = new TestArray();
            tm.ToObject(document, t);

            Assert.NotNull(t.values);
            Assert.Equal(5, t.values.Length);
            Assert.Equal(3, t.values[2]);

            ODocument newODocument = ODocument.ToDocument(t);
            var serialized = Encoding.UTF8.GetString(serializer.Serialize(newODocument));
            Assert.Equal(recordString, serialized);
        }
Ejemplo n.º 16
0
    private static int Main()
    {
#if !MULTIMODULE_BUILD
        TestLdstr.Run();
        TestException.Run();
        TestThreadStaticNotInitialized.Run();
        TestUntouchedThreadStaticInitialized.Run();
        TestPointers.Run();
        TestConstants.Run();
        TestArray.Run();
        TestArrayOutOfRange.Run();
        TestMdArray.Run();
        TestSimpleObject.Run();
        TestFinalizableObject.Run();
        TestStoreIntoOtherStatic.Run();
        TestCctorCycle.Run();
        TestReferenceTypeAllocation.Run();
        TestReferenceTypeWithGCPointerAllocation.Run();
        TestReferenceTypeWithReadonlyNullGCPointerAllocation.Run();
        TestRelationalOperators.Run();
        TestTryFinally.Run();
        TestTryCatch.Run();
        TestBadClass.Run();
        TestRefs.Run();
        TestDelegate.Run();
        TestInitFromOtherClass.Run();
        TestInitFromOtherClassDouble.Run();
        TestDelegateToOtherClass.Run();
        TestLotsOfBackwardsBranches.Run();
        TestDrawCircle.Run();
        TestValueTypeDup.Run();
        TestFunctionPointers.Run();
        TestGCInteraction.Run();
        TestDuplicatedFields.Run();
        TestInstanceDelegate.Run();
#else
        Console.WriteLine("Preinitialization is disabled in multimodule builds for now. Skipping test.");
#endif

        return(100);
    }
Ejemplo n.º 17
0
        public IEnumerator ArrayRemove()
        {
            yield return(T().YieldWait()); async Task T()
            {
                var ta = new TestArray {
                    array1 = new List <object> {
                        11, "hey"
                    },
                    array2 = new List <object> {
                        44, "yo", 55, 66, 77, 88
                    },
                    array3 = new List <object> {
                        66, "wow"
                    },
                };
                await TestDocument1.SetAsync <TestArray>(ta);

                await TestDocument1.ArrayRemoveAsync("array2", new object[] { 66, 77 });

                var returned = (await TestDocument1.GetSnapshotAsync()).ConvertTo <TestArray>();

                Assert.That(returned.array1.Count, Is.EqualTo(2));
                Assert.That(returned.array2.Count, Is.EqualTo(4));
                Assert.That(returned.array3.Count, Is.EqualTo(2));

                Assert.That(returned.array2[0], Is.EqualTo(44));
                Assert.That(returned.array2[1], Is.EqualTo("yo"));
                Assert.That(returned.array2[2], Is.EqualTo(55));
                Assert.That(returned.array2[3], Is.EqualTo(88));

                await TestDocument1.ArrayRemoveAsync("array2", new object[] { 555555 });

                returned = (await TestDocument1.GetSnapshotAsync()).ConvertTo <TestArray>();

                Assert.That(returned.array2.Count, Is.EqualTo(4), "Removing something that is not in array cause nothing.");
                Assert.That(returned.array2[0], Is.EqualTo(44));
                Assert.That(returned.array2[1], Is.EqualTo("yo"));
                Assert.That(returned.array2[2], Is.EqualTo(55));
                Assert.That(returned.array2[3], Is.EqualTo(88));
            }
        }
    public static void printTestArray(TestArray testArray)
    {
        String display = "";

        for (int i = 0; i < testArray.codes.Length; i++)
        {
            display += testArray.codes[i] + " ";
        }
        display += "\n";
        for (int i = 0; i < testArray.values.Length; i++)
        {
            display += testArray.values[i] + " ";
        }
        display += "\n";
        for (int i = 0; i < testArray.codes.Length; i++)
        {
            display += testArray.answers[i] + " ";
        }
        display += "\n";
        Console.Out.WriteLine(display);
    }
        public async Task UpdateExperienceDiffsAsync_RequirePermissionsAsyncSucceeds_ReturnsUpdateExperienceDiffsAsync(
            ulong currentUserId)
        {
            using var testContext = new TestContext();

            testContext.SetCurrentUserId(currentUserId);

            var mockError = new Mock <OperationError>("Mock Message");

            testContext.MockCharacterLevelsService
            .Setup(x => x.UpdateExperienceDiffsAsync(
                       It.IsAny <IReadOnlyList <int> >(),
                       It.IsAny <ulong>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(OperationResult.FromError(mockError.Object));

            var uut = testContext.BuildUut();

            var experienceThresholds = TestArray.Unique <int>();

            var result = await uut.UpdateExperienceDiffsAsync(
                experienceThresholds,
                testContext.CancellationToken);

            result.IsFailure.ShouldBeTrue();
            result.Error.ShouldBeSameAs(mockError.Object);

            testContext.MockAuthorizationService.ShouldHaveReceived(x => x
                                                                    .RequirePermissionsAsync(
                                                                        It.Is <int[]>(y => (y != null) && (y.Length != 0)),
                                                                        testContext.CancellationToken));

            testContext.MockCharacterLevelsService.ShouldHaveReceived(x => x
                                                                      .UpdateExperienceDiffsAsync(
                                                                          experienceThresholds,
                                                                          currentUserId,
                                                                          testContext.CancellationToken));
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            int[] myArray = { 23, 44, 55, 12, 6, 99 };

            //2c:
            Console.WriteLine("The values in the array are:");
            for (int a = 0; a < myArray.Length; a++)
            {
                Console.WriteLine(myArray[a]);
            }

            //2d:
            ArrayMethod(myArray);

            Console.WriteLine();

            //2f:
            TestArray testAry = new TestArray("Array of values above 50:");
            //2g:
            testAry.AryDisplay(myArray);

            Console.ReadKey();
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            int[] myArray = { 23, 44, 55, 12, 6, 99 };

            //2c:
            Console.WriteLine("The values in the array are:");
            for (int a = 0; a < myArray.Length; a++)
            {
                Console.WriteLine(myArray[a]);
            }

            //2d:
            ArrayMethod(myArray);

            Console.WriteLine();

            //2f:
            TestArray testAry = new TestArray("Array of values above 50:");

            //2g:
            testAry.AryDisplay(myArray);

            Console.ReadKey();
        }
Ejemplo n.º 22
0
    void test()
    {
        TestArray test = new TestArray();

        test.s1[10] = new TestValue();
    }
Ejemplo n.º 23
0
    public static void Init()
    {
        Clear();
        string    jsonTest   = ((TextAsset)Resources.Load("GameDataConfig")).text;
        TestArray jsonObject = JsonUtility.FromJson <TestArray>(jsonTest);

        if (jsonObject == null)
        {
            Debug.LogError("GameDataConfig data null");
        }


        if (jsonObject.Hero == null)
        {
            Debug.LogError("Hero data null");
        }
        foreach (HeroPrototype item in jsonObject.Hero)
        {
            mHeroDict[item.ID] = item;
        }

        if (jsonObject.Item == null)
        {
            Debug.LogError("Item data null");
        }
        foreach (ItemPrototype item in jsonObject.Item)
        {
            mItemDict[item.ID] = item;
        }

        if (jsonObject.Skill == null)
        {
            Debug.LogError("Skill data null");
        }
        foreach (SkillPrototype item in jsonObject.Skill)
        {
            mSkillDict[item.ID] = item;
        }

        if (jsonObject.District == null)
        {
            Debug.LogError("District data null");
        }
        foreach (DistrictPrototype item in jsonObject.District)
        {
            mDistrictDict[item.ID] = item;
        }

        if (jsonObject.DistrictGrid == null)
        {
            Debug.LogError("DistrictGrid data null");
        }
        foreach (DistrictGridPrototype item in jsonObject.DistrictGrid)
        {
            mDistrictGridDict[item.ID] = item;
        }

        if (jsonObject.Building == null)
        {
            Debug.LogError("Building data null");
        }
        foreach (BuildingPrototype item in jsonObject.Building)
        {
            mBuildingDict[item.ID] = item;
        }

        if (jsonObject.Dungeon == null)
        {
            Debug.LogError("Dungeon data null");
        }
        foreach (DungeonPrototype item in jsonObject.Dungeon)
        {
            mDungeonDict[item.ID] = item;
        }

        if (jsonObject.Monster == null)
        {
            Debug.LogError("Monster data null");
        }
        foreach (MonsterPrototype item in jsonObject.Monster)
        {
            mMonsterDict[item.ID] = item;
        }

        if (jsonObject.Lemma == null)
        {
            Debug.LogError("Lemma data null");
        }
        foreach (LemmaPrototype item in jsonObject.Lemma)
        {
            mLemmaDict[item.ID] = item;
        }

        if (jsonObject.ProduceEquip == null)
        {
            Debug.LogError("ProduceEquip data null");
        }
        foreach (ProduceEquipPrototype item in jsonObject.ProduceEquip)
        {
            mProduceEquipDict[item.ID] = item;
        }

        if (jsonObject.ProduceResource == null)
        {
            Debug.LogError("ProduceResource data null");
        }
        foreach (ProduceResourcePrototype item in jsonObject.ProduceResource)
        {
            mProduceResourceDict[item.ID] = item;
        }

        if (jsonObject.Technology == null)
        {
            Debug.LogError("Technology data null");
        }
        foreach (TechnologyPrototype item in jsonObject.Technology)
        {
            mTechnologyDict[item.ID] = item;
        }

        if (jsonObject.AreaPath == null)
        {
            Debug.LogError("AreaPath data null");
        }
        foreach (AreaPathPrototype item in jsonObject.AreaPath)
        {
            mAreaPathDict[item.Type + "-" + item.StartDistrict + "-" + item.EndDistrict] = item;
        }

        if (jsonObject.AreaPathPoint == null)
        {
            Debug.LogError("AreaPathPoint data null");
        }
        foreach (AreaPathPointPrototype item in jsonObject.AreaPathPoint)
        {
            mAreaPathPointDict[item.ID] = item;
        }

        if (jsonObject.Characteristic == null)
        {
            Debug.LogError("Characteristic data null");
        }
        foreach (CharacteristicPrototype item in jsonObject.Characteristic)
        {
            mCharacteristicDict[item.ID] = item;
        }


        if (jsonObject.ItemSuite == null)
        {
            Debug.LogError("ItemSuite data null");
        }
        foreach (ItemSuitePrototype item in jsonObject.ItemSuite)
        {
            mItemSuiteDict[item.ID] = item;
        }

        if (jsonObject.Consumable == null)
        {
            Debug.LogError("Consumable data null");
        }
        foreach (ConsumablePrototype item in jsonObject.Consumable)
        {
            mConsumableDict[item.ID] = item;
        }

        if (jsonObject.Halo == null)
        {
            Debug.LogError("Halo data null");
        }
        foreach (HaloPrototype item in jsonObject.Halo)
        {
            mHaloDict[item.ID] = item;
        }
    }
Ejemplo n.º 24
0
    public void testCase1()
    {
        //測試array是否傳指標
        TestArray tArray=new TestArray();
        int[] a =tArray.getA();
        a[0] = 60;
        tArray.show();
        tArray.reset();
        tArray.show();

        Debug.Log("outside");
        foreach (int i in a)
            Debug.Log(i);
    }
Ejemplo n.º 25
0
 /// <summary>
 /// Tests a list of types
 /// </summary>
 /// <param name="Types">Types to test</param>
 /// <returns>XML string containing the results</returns>
 public string Test(Type[] Types)
 {
     return((string)TestArray.Invoke(MoonUnitManager, new object[] { Types }));
 }
Ejemplo n.º 26
0
 protected void Init(int blockSize)
 {
     array = new TestArray <string>(blockSize);
 }