Beispiel #1
0
        public virtual async Task EnumTest_CSClient()
        {
            using (BitOwinTestEnvironment testEnvironment = new BitOwinTestEnvironment(new TestEnvironmentArgs {
            }))
            {
                TokenResponse token = await testEnvironment.Server.Login("ValidUserName", "ValidPassword", clientId : "TestResOwner");

                IODataClient client = testEnvironment.Server.BuildODataClient(token: token);

                DtoWithEnum dtoWithEnum = await client.DtoWithEnum()
                                          .GetDtoWithEnumsByGender(TestGender.Man)
                                          .ExecuteAsSingleAsync();

                Assert.AreEqual(TestGender.Man, dtoWithEnum.Gender);

                Assert.AreEqual(true, await client.DtoWithEnum()
                                .PostDtoWithEnum(dtoWithEnum)
                                .ExecuteAsScalarAsync <bool>());

                ODataBatch batchClient = testEnvironment.Server.BuildODataBatchClient(token: token);

                batchClient += bc => bc.DtoWithEnum()
                               .GetDtoWithEnumsByGender2(TestGender2.Man)
                               .ExecuteAsEnumerableAsync();

                batchClient += bc => bc.DtoWithEnum()
                               .GetDtoWithEnumsByGender(TestGender.Man)
                               .ExecuteAsEnumerableAsync();

                await batchClient.ExecuteAsync();

                /*Assert.AreEqual(true, await client.DtoWithEnum()
                 *  .TestEnumsArray(new[] { TestGender2.Man, TestGender2.Woman })
                 *  .ExecuteAsScalarAsync<bool>());*/

                DtoWithEnumController firstCallController = TestDependencyManager.CurrentTestDependencyManager.Objects
                                                            .OfType <DtoWithEnumController>()
                                                            .First();

                DtoWithEnumController secondCallController = TestDependencyManager.CurrentTestDependencyManager.Objects
                                                             .OfType <DtoWithEnumController>()
                                                             .ElementAt(2);

                A.CallTo(() => firstCallController.GetDtoWithEnumsByGender(TestGender.Man))
                .MustHaveHappenedOnceExactly();

                A.CallTo(() => secondCallController.GetDtoWithEnumsByGender2(TestGender2.Man))
                .MustHaveHappenedOnceExactly();
            }
        }