Esempio n. 1
0
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Calling Item Property ,T is user define type. ");
        try
        {
            IList <MyTestClass> myList      = new List <MyTestClass>();
            MyTestClass         expectValue = new MyTestClass();
            expectValue.ID = 100;
            myList.Add(expectValue);
            int         index       = 0;
            MyTestClass actualValue = myList[index];

            if (!actualValue.Equals(expectValue))
            {
                TestLibrary.TestFramework.LogError("003.1", "the method of Item property get can not return the correct value.");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e);
            retVal = false;
        }
        return(retVal);
    }
            protected override void Context()
            {
                base.Context();

                Source = Builder<MyTestClass>.CreateNew().Build();
                Target = new MyTestClass();
            }
Esempio n. 3
0
        public void CanWriteInTransactionScopeAndReadOutsideOfTransactionScope()
        {
            using (var server = GetNewServer(requestedStorage: "esent"))
            {
                EnsureDtcIsSupported(server);

                using (var store = new DocumentStore {
                    Url = "http://localhost:8079"
                }.Initialize())
                {
                    var testEntity = new MyTestClass()
                    {
                        SomeText = "Foo"
                    };

                    using (var ts = new TransactionScope())
                    {
                        using (var session = store.OpenSession())
                        {
                            session.Store(testEntity);
                            session.SaveChanges();
                        }
                        ts.Complete();
                    }

                    using (var session = store.OpenSession())
                    {
                        session.Advanced.AllowNonAuthoritativeInformation = false;
                        var testEntityRetrieved = session.Load <MyTestClass>(testEntity.Id);
                        Assert.Equal(testEntityRetrieved.SomeText, testEntity.SomeText);
                    }
                }
            }
        }
Esempio n. 4
0
 public void SetUp()
 {
     _faker = new FackerProgram.Faker();
     _faker.DTOAdd(typeof(Foo));
     _faker.DTOAdd(typeof(Bar));
     result = _faker.Create <MyTestClass>();
 }
Esempio n. 5
0
 public void ExitNullArgumentValidLevel3Test()
 {
     testClass1                     = new MyTestClass();
     testClass1.MyString            = "Hello";
     testClass1.MyPropertyTestClass = new MyPropertyTestClass();
     testClass1.MyPropertyTestClass.MyOtherString = "Hello";
 }
        public void GetValueFromResponse_Returns_Null_Not_Found_Property()
        {
            var userServiceMock   = new Mock <IUserService>();
            var userService       = userServiceMock.Object;
            var entityServiceMock = new Mock <IEntityService>();
            var entityService     = entityServiceMock.Object;

            var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable <ContentItemBasic>), "DontFind", userService, entityService);
            var val = new List <ContentItemBasic>()
            {
                new ContentItemBasic()
            };
            var container = new MyTestClass()
            {
                MyList = val
            };

            var result = att.GetValueFromResponse(
                new ObjectContent(typeof(MyTestClass),
                                  container,
                                  new JsonMediaTypeFormatter(),
                                  new MediaTypeHeaderValue("html/text")));

            Assert.AreEqual(null, result);
        }
Esempio n. 7
0
        public void DbAppSetting_customObect()
        {
            MyTestClassSetting setting = new MyTestClassSetting();

            Assert.IsTrue(setting.InitialValue.SomeProperty == 1);
            Assert.IsTrue(setting.InitialValue.SomeOtherProperty == "Test");
            Assert.IsTrue(setting.InternalValue.SomeProperty == 1);
            Assert.IsTrue(setting.InternalValue.SomeOtherProperty == "Test");

            MyTestClass testClass = new MyTestClass();

            testClass.SomeProperty      = 2;
            testClass.SomeOtherProperty = "Test2";

            string jsonTestClass = new JavaScriptSerializer().Serialize(testClass);

            DbAppSettingDto settingDto = new DbAppSettingDto()
            {
                Key = setting.FullSettingName, Value = jsonTestClass, Type = setting.TypeString
            };

            setting.From(settingDto);

            Assert.IsTrue(setting.InitialValue.SomeProperty == 1);
            Assert.IsTrue(setting.InitialValue.SomeOtherProperty == "Test");
            Assert.IsTrue(setting.InternalValue.SomeProperty == 2);
            Assert.IsTrue(setting.InternalValue.SomeOtherProperty == "Test2");

            DbAppSettingDto toDto = setting.ToDto();

            Assert.IsTrue(toDto.ApplicationKey == settingDto.ApplicationKey);
            Assert.IsTrue(toDto.Key == settingDto.Key);
            Assert.IsTrue(toDto.Type == settingDto.Type);
            Assert.IsTrue(toDto.Value.Equals(settingDto.Value, StringComparison.InvariantCultureIgnoreCase));
        }
Esempio n. 8
0
        public void CanWriteInTransactionScopeAndReadFromAnotherTransactionScope()
        {
            using (GetNewServer())
                using (var store = new DocumentStore {
                    Url = "http://localhost:8080"
                }.Initialize())
                {
                    var testEntity = new MyTestClass()
                    {
                        SomeText = "Foo"
                    };

                    using (var ts = new TransactionScope())
                    {
                        using (var session = store.OpenSession())
                        {
                            session.Store(testEntity);
                            session.SaveChanges();
                        }
                        ts.Complete();
                    }

                    using (var ts = new TransactionScope())
                    {
                        using (var session = store.OpenSession())
                        {
                            session.Advanced.AllowNonAuthoritiveInformation = false;
                            var testEntityRetrieved = session.Load <MyTestClass>(testEntity.Id);
                            Assert.Equal(testEntityRetrieved.SomeText, testEntity.SomeText);
                        }
                    }
                }
        }
Esempio n. 9
0
        public void CanWriteInTransactionScopeAndReadFromAnotherTransactionScope()
        {
            using (var server = GetNewServer(requestedStorage: "esent"))
            {
                EnsureDtcIsSupported(server);

                using (var store = new DocumentStore { Url = "http://localhost:8079" }.Initialize())
                {
                    var testEntity = new MyTestClass() { SomeText = "Foo" };

                    using (var ts = new TransactionScope())
                    {
                        using (var session = store.OpenSession())
                        {
                            session.Store(testEntity);
                            session.SaveChanges();
                        }
                        ts.Complete();
                    }

                    using (var ts = new TransactionScope())
                    {
                        using (var session = store.OpenSession())
                        {
                            session.Advanced.AllowNonAuthoritativeInformation = false;
                            var testEntityRetrieved = session.Load<MyTestClass>(testEntity.Id);
                            Assert.Equal(testEntityRetrieved.SomeText, testEntity.SomeText);
                        }
                    }
                }
            }
        }
Esempio n. 10
0
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest4()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest4: Calling indexof method ,T is user define type,the item is not exist int the List. ");
        try
        {
            IList <MyTestClass> myList = new List <MyTestClass>();
            MyTestClass         myTest = null;
            for (int i = 1; i <= 10; i++)
            {
                myTest    = new MyTestClass();
                myTest.ID = i;
                myList.Add(myTest);
            }
            int expectValue = -1;
            myTest    = new MyTestClass();
            myTest.ID = 100;
            int actualValue = myList.IndexOf(myTest);
            if (actualValue != expectValue)
            {
                TestLibrary.TestFramework.LogError("004.1", "Calling IndexOf method return a value correctly.");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004.0", "Unexpected exception: " + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 11
0
        public void Setup()
        {
            List <byte[]>      bytesList   = new List <byte[]>(Size);
            List <byte[]>      bytesList2  = new List <byte[]>(Size);
            List <byte[]>      bytesList3  = new List <byte[]>(Size);
            List <MyTestClass> testClasses = new List <MyTestClass>(Size);

            var bogus = new Bogus.Randomizer();

            for (int i = 0; i < Size; i++)
            {
                MyTestClass myTestClass = new MyTestClass();
                myTestClass.BoolProp = bogus.Bool();
                myTestClass.IntList  = new List <int>(100);
                for (int j = 0; j < 100; j++)
                {
                    myTestClass.IntList.Add(bogus.Int());
                }

                myTestClass.StringProp  = bogus.String(10, 100);
                myTestClass.StringProp2 = bogus.String(10, 100);

                bytesList.Add(JsonSerializer.Serialize(myTestClass));
                bytesList3.Add(System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(myTestClass));
                bytesList2.Add(MessagePack.MessagePackSerializer.Typeless.Serialize(myTestClass, ContractlessStandardResolver.Options));
                testClasses.Add(myTestClass);
            }

            _serializedObjectsUtf8Json    = bytesList.ToArray();
            _serializedObjectsMessagePack = bytesList2.ToArray();
            _serializedObjectsTextJson    = bytesList3.ToArray();
            _testClasses = testClasses.ToArray();
        }
Esempio n. 12
0
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool NegTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest1: index is not a valid index in the IList.");
        try
        {
            IList <MyTestClass> myList      = new List <MyTestClass>();
            MyTestClass         expectValue = new MyTestClass();
            expectValue.ID = 100;
            myList.Add(expectValue);
            int         index       = 100;
            MyTestClass actualValue = myList[index];
            TestLibrary.TestFramework.LogError("101.1", "ArgumentOutOfRangeException should be caught.");
            retVal = false;
        }
        catch (ArgumentOutOfRangeException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("101.0", "Unexpected exception: " + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 13
0
        public void _ConditionalValue_IsConvertedToTheSameInstance_WhenValuePresent()
        {
            var         myValue          = new MyTestClass();
            MyTestClass conditionalValue = ConditionalValue.From(new MyTestClass());

            (myValue == conditionalValue).Should().BeFalse();
        }
        public async Task GetDocuments_ShouldSucceed()
        {
            const int NUM_DOCS         = 3;
            var       postDocResponses = new PostDocumentResponse <MyTestClass> [NUM_DOCS];

            for (int i = 0; i < NUM_DOCS; i++)
            {
                var document = new MyTestClass {
                    Message = "Test " + i
                };
                postDocResponses[i] = await _docClient.PostDocumentAsync(_testCollection, document);
            }

            var getDocsResponse = await _docClient.GetDocumentsAsync <MyTestClass>(
                _testCollection,
                postDocResponses.Select(r => r._key).ToList());

            Assert.Equal(NUM_DOCS, getDocsResponse.Count);
            for (int i = 0; i < NUM_DOCS; i++)
            {
                var getDocResponse = getDocsResponse.FirstOrDefault(doc => doc._key == postDocResponses[i]._key);
                Assert.NotNull(getDocResponse);
                Assert.Equal(postDocResponses[i]._rev, getDocResponse._rev);
                Assert.Equal(postDocResponses[i]._id, getDocResponse._id);
            }
        }
        public void PerformOnConnection_Verify_Mapper_Called_On_DataReader()
        {
            IResultMapper <MyTestClass> mockMapper = MockRepository.GenerateMock <IResultMapper <MyTestClass> >();

            var mockTestClass = new MyTestClass();

            this.DataReader.Stub(x => x.Read())
            .Repeat
            .Once()
            .Return(true);

            //mock no fields so that no query structure is populated as we do not care about
            //it in this test
            this.DataReader.Stub(x => x.FieldCount)
            .Return(0);


            mockMapper.Expect(x => x.MapResult(Arg <IDataReader> .Is.Equal(this.DataReader), Arg <QueryResultStructure> .Is.Anything))
            .Return(mockTestClass);

            var result = RetrievalQueryExecutorBuilder <MyTestClass> .ForQuery("QUERY")
                         .WithCustomResultMapper(mockMapper)
                         .Build()
                         .PerformOnConnection(this.Connection);

            mockMapper.VerifyAllExpectations();

            Assert.AreSame(mockTestClass, result.First(), "Did not return the expected mapped object");
        }
Esempio n. 16
0
    public static MyTestClass BuildMyTestClass()
    {
        MyTestClass myTestClass = new MyTestClass();

        myTestClass._id = new ObjectId("testclassid");

        myTestClass.myString = "Hello World!";
        myTestClass.myInt    = 100;
        myTestClass.myBool   = true;
        myTestClass.myFloat  = 0.1234567f;

        myTestClass.myStringArray = new string[] { "ar_one", "ar_two", "ar_three" };
        myTestClass.myStringList  = new List <string>()
        {
            "list_one", "list_two", "list_three"
        };

        myTestClass.myFloatArray = new float[] { 0.1f, 0.12f, 1.23f };
        myTestClass.myIntList    = new List <int>()
        {
            3, 2, 1
        };

        myTestClass.myDate = DateTime.Now.ToUniversalTime();

        // this.myPlayerInfo = new PlayerInfo("Randy", 10, 1234);
        myTestClass.mySpecialItem = new TestItem("Special", 2, 299);

        myTestClass.myInventory.Add(new TestItem("Shield", 1, 100));
        myTestClass.myInventory.Add(new TestItem("Potion", 1, 100));
        myTestClass.myInventory.Add(new TestItem("Sword", 100, 0));

        return(myTestClass);
    }
Esempio n. 17
0
		public void CanWriteInTransactionScopeAndReadOutsideOfTransactionScope()
		{
			using(GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8080" }.Initialize())
			{
				var testEntity = new MyTestClass() {SomeText = "Foo"};

				using (var ts = new TransactionScope())
				{
					using (var session = store.OpenSession())
					{
						session.Store(testEntity);
						session.SaveChanges();
					}
					ts.Complete();
				}

				using (var session = store.OpenSession())
				{
					session.Advanced.AllowNonAuthoritiveInformation = false;
					var testEntityRetrieved = session.Load<MyTestClass>(testEntity.Id);
					Assert.Equal(testEntityRetrieved.SomeText, testEntity.SomeText);
				}
			}
		}
Esempio n. 18
0
        public void Feature_Equals_GetHashCode_Contract_Properties_Of_Objects()
        {
            // order of keys should not matter

            var leftProp = new MyTestClass
            {
                StringProperty   = "Hello, GeoJSON !",
                EnumProperty     = MyTestEnum.Value1,
                IntProperty      = -1,
                BooleanProperty  = true,
                DateTimeProperty = DateTime.Now,
                DoubleProperty   = 1.2345d
            };

            var left = new Net.Feature.Feature(new Point(new GeographicPosition(10, 10)), leftProp);

            var rightProp = new MyTestClass
            {
                BooleanProperty  = true,
                DateTimeProperty = DateTime.Now,
                DoubleProperty   = 1.2345d,
                EnumProperty     = MyTestEnum.Value1,
                IntProperty      = -1,
                StringProperty   = "Hello, GeoJSON !"
            };

            var right = new Net.Feature.Feature(new Point(new GeographicPosition(10, 10)), rightProp);

            Assert_Are_Equal(left, right);
        }
Esempio n. 19
0
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Calling indexof method ,T is user define type. ");
        try
        {
            IList <MyTestClass> myList = new List <MyTestClass>();
            MyTestClass         myTest = null;
            for (int i = 1; i <= 10; i++)
            {
                myTest    = new MyTestClass();
                myTest.ID = i;
                myList.Add(myTest);
            }
            int         index       = 1;
            MyTestClass expectValue = new MyTestClass();
            expectValue.ID = 999;
            myList.Insert(index, expectValue);
            MyTestClass actualValue = myList[index];
            if (actualValue != expectValue)
            {
                TestLibrary.TestFramework.LogError("003.1", "Calling IndexOf method return a value incorrectly,should return " + expectValue);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 20
0
        private void button1_Click(object sender, EventArgs e)
        {
            var testClass = new MyTestClass();

            var message = string.Format("Version {0} of external assembly", testClass.MyVersion());
            
            MessageBox.Show(message, "Information", MessageBoxButtons.OK);
        }
        public void CreateMappingCollection_Verify_Private_Properties_Mapped()
        {
            var myObject = new MyTestClass();

            var result = ObjectFieldMappingCollection.CreateMappingCollection(myObject);

            Assert.NotNull(result.GetFieldInfo("B"));
        }
Esempio n. 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            var testClass = new MyTestClass();

            var message = string.Format("Version {0} of external assembly", testClass.MyVersion());

            MessageBox.Show(message, "Information", MessageBoxButtons.OK);
        }
            protected override void Context()
            {
                base.Context();

                Source = Builder <MyTestClass> .CreateNew().Build();

                Target = new MyTestClass();
            }
Esempio n. 24
0
        public void TestParamsLengthZero()
        {
            var obj = new MyTestClass();
            // Check that passing no parameters to the 'params' parameter (empty array) works
            var result = ClrFacade.CallInstanceMethod(obj, "UniqueNameStrStrParams", new[] { "", "" });

            // However, if it means that there are more than one candidate methods:
            Assert.Throws <AmbiguousMatchException>(() => { ClrFacade.CallInstanceMethod(obj, "StringSameNameParams", new[] { "" }); });
        }
        public void RegularExpressionAttributeTest()
        {
            var entity     = new MyTestClass();
            var validatior = new EntityValidator(entity);

            entity.RegExprProperty = "abc";
            Assert.IsTrue(entity.HasValidationErrors);
            entity.RegExprProperty = "abcdef";
            Assert.IsFalse(entity.HasValidationErrors);
        }
        public void RequiredAttributeStringTest()
        {
            var entity     = new MyTestClass();
            var validatior = new EntityValidator(entity);

            entity.StringProperty = null;
            Assert.IsTrue(entity.HasValidationErrors);
            entity.StringProperty = "";
            Assert.IsFalse(entity.HasValidationErrors);
        }
Esempio n. 27
0
        public void Assign_calls_Defaults_action()
        {
            var myTestClass = new MyTestClass();
            var sut         = DefaultValuesProvider <MyTestClass> .Create(m =>
            {
                m.HasChanged = true;
            });

            sut.Assign(myTestClass);
            Assert.True(myTestClass.HasChanged);
        }
Esempio n. 28
0
    void MyTest()
    {
        var        myclass = new MyTestClass();
        MethodInfo method  = myclass.GetType().GetMethod("MyTestFunc");

        ParameterInfo[] parameterInfos = method.GetParameters();
        foreach (ParameterInfo param in parameterInfos)
        {
            Debug.LogError(param.Name + param.ParameterType.IsByRef + "_" + param.ParameterType);
        }
    }
Esempio n. 29
0
        static void Main(string[] args)
        {
            var myTestClass = new MyTestClass();

            myTestClass.Run();

            var logger = new GeneralLogger();

            var providerSettings = new TestJobsProviderSettings
            {
                SearchInAssemblyName = "AsyncNet.Selenium.Tests"
            };

            var jobsProvider    = new TestJobsProvider(providerSettings);
            var managerSettings = new JobsManagerSettings();
            var jobsManager     = new TestJobsManager(jobsProvider, managerSettings);

            jobsManager.OnStart               += (s, e) => logger.Info("PROCESS START");
            jobsManager.OnFailed              += (s, e) => logger.Info("PROCESS FAILED");
            jobsManager.OnFinished            += (s, e) => logger.Info("PROCESS FINISHED");
            jobsManager.OnActionExecuting     += (s, e) => logger.Info("START - " + ((TestCaseJob)s).TestCaseType.Name);
            jobsManager.OnActionExecuted      += (s, e) => logger.Info("STOP  - " + ((TestCaseJob)s).TestCaseType.Name);
            jobsManager.OnActionCanceled      += (s, e) => logger.Info("CANCELLED - " + ((TestCaseJob)s).TestCaseType.Name);
            jobsManager.OnActionFailed        += (s, e) => logger.Info("FAILED - " + ((TestCaseJob)s).TestCaseType.Name + " Exception: " + e.Exception.ToString());
            jobsManager.OnBackActionExecuting += (s, e) => logger.Info("BACK START - " + ((TestCaseJob)s).TestCaseType.Name);
            jobsManager.OnBackActionExecuted  += (s, e) => logger.Info("BACK STOP  - " + ((TestCaseJob)s).TestCaseType.Name);
            jobsManager.OnBackActionFailed    += (s, e) => logger.Info("BACK FAILED - " + ((TestCaseJob)s).TestCaseType.Name + " Exception: " + e.Exception.ToString());
            jobsManager.OnStateChanged        += (s, e) => logger.Info("STATE CHANGED - " + ((TestCaseJob)s).State.ToString() + " - " + ((TestCaseJob)s).TestCaseType.Name);

            jobsManager.BeginRun();

            bool ask = true;

            while (ask)
            {
                Console.WriteLine("c - Cancel, t - Terminate, q - Quit");
                var key = Console.ReadKey().KeyChar;

                switch (key)
                {
                case 'c':
                    jobsManager.Cancel();
                    break;

                case 't':
                    jobsManager.Terminate();
                    break;

                case 'q':
                    ask = false;
                    break;
                }
            }
        }
            protected override void Context()
            {
                base.Context();

                Source = Builder <MyTestClass> .CreateNew().Build();

                Target = new MyTestClass
                {
                    Age  = Source.Age,
                    Name = Source.Name,
                };
            }
        public void Serialize_Class_Test()
        {
            var source = new MyTestClass
            {
                Field1 = 42,
                Field2 = "Stranger Things"
            };

            var result = _redisCacheSerializer.Serialize(source, typeof(MyTestClass));

            result.ToString().ShouldBe("{\"Payload\":\"{\\\"Field1\\\":42,\\\"Field2\\\":\\\"Stranger Things\\\"}\",\"Type\":\"Abp.RedisCache.Tests.DefaultRedisCacheSerializer_Tests+MyTestClass, Abp.RedisCache.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\"}");
        }
Esempio n. 32
0
        public void Serialize_Class_Test()
        {
            var source = new MyTestClass
            {
                Field1 = 42,
                Field2 = "Stranger Things"
            };

            var result = _redisCacheSerializer.Serialize(source, typeof(MyTestClass));

            result.ShouldBe("{\"Payload\":\"{\\\"Field1\\\":42,\\\"Field2\\\":\\\"Stranger Things\\\"}\",\"Type\":\"Abp.RedisCache.Tests.DefaultRedisCacheSerializer_Tests+MyTestClass, Abp.RedisCache.Tests\"}");
        }
Esempio n. 33
0
 protected override void InitializeCore()
 {
     rangeClass  = new MyTestClass();
     int32Info   = rangeClass.GetType().GetProperty("Int32Value");
     doubleInfo  = rangeClass.GetType().GetProperty("DoubleValue");
     floatInfo   = rangeClass.GetType().GetProperty("FloatValue");
     charInfo    = rangeClass.GetType().GetProperty("CharValue");
     stringInfo  = rangeClass.GetType().GetProperty("StringValue");
     shortInfo   = rangeClass.GetType().GetProperty("ShortValue");
     byteInfo    = rangeClass.GetType().GetProperty("ByteValue");
     decimalInfo = rangeClass.GetType().GetProperty("DecimalValue");
 }
        protected override void InitializeCore()
        {
            rangeClass = new MyTestClass();
            int32Info = rangeClass.GetType().GetProperty("Int32Value");            
            doubleInfo = rangeClass.GetType().GetProperty("DoubleValue");            
            floatInfo = rangeClass.GetType().GetProperty("FloatValue");            
            charInfo = rangeClass.GetType().GetProperty("CharValue");            
            stringInfo = rangeClass.GetType().GetProperty("StringValue");
			shortInfo = rangeClass.GetType().GetProperty("ShortValue");
			byteInfo = rangeClass.GetType().GetProperty("ByteValue");
			decimalInfo = rangeClass.GetType().GetProperty("DecimalValue");           
        }
Esempio n. 35
0
        public void Test1()
        {
            //Assert.Pass();

            // ARRANGE
            var handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict);

            handlerMock
            .Protected()
            // Setup the PROTECTED method to mock
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>()
                )
            // prepare the expected response of the mocked http call
            .ReturnsAsync(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("[{'id':1,'value':'1'}]"),
            })
            .Verifiable();

            // use real http client with mocked handler here
            var httpClient = new HttpClient(handlerMock.Object)
            {
                BaseAddress = new Uri("http://test.com/"),
            };

            var subjectUnderTest = new MyTestClass(httpClient);

            // ACT
            var result = await subjectUnderTest
                         .GetSomethingRemoteAsync("api/test/whatever");

            // ASSERT
            result.Should().NotBeNull(); // this is fluent assertions here...
            result.Id.Should().Be(1);

            // also check the 'http' call was like we expected it
            var expectedUri = new Uri("http://test.com/api/test/whatever");

            handlerMock.Protected().Verify(
                "SendAsync",
                Times.Exactly(1), // we expected a single external request
                ItExpr.Is <HttpRequestMessage>(req =>
                                               req.Method == HttpMethod.Get && // we expected a GET request
                                               req.RequestUri == expectedUri // to this uri
                                               ),
                ItExpr.IsAny <CancellationToken>()
                );
        }
        public void GetValueFromResponse_Returns_Null_Not_Found_Property()
        {
            var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>), "DontFind");
            var val = new List<ContentItemBasic>() { new ContentItemBasic() };
            var container = new MyTestClass() { MyList = val };

            var result = att.GetValueFromResponse(
                new ObjectContent(typeof(MyTestClass),
                                  container,
                                  new JsonMediaTypeFormatter(),
                                  new MediaTypeHeaderValue("html/text")));

            Assert.AreEqual(null, result);

        }
        public void Can_Get_Correct_ReferenceType_Property_Value()
        {
            var referenceTypeProperty = typeof(MyTestClass).GetProperty("ReferenceTypeProperty", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsNotNull(referenceTypeProperty);
            var referenceTypePropertyValueGetter = referenceTypeProperty.GetValueGetter();
            Assert.IsNotNull(referenceTypePropertyValueGetter);

            var testClass = new MyTestClass();

            object nullValue = referenceTypePropertyValueGetter(testClass);
            Assert.IsNull(nullValue);

            testClass.ReferenceTypeProperty = "418";
            object fourOneEightValue = referenceTypePropertyValueGetter(testClass);
            Assert.IsInstanceOfType(fourOneEightValue, typeof(string));
            Assert.AreEqual("418", fourOneEightValue);
        }
        public void Can_Get_Correct_NullableType_PropertyValue()
        {
            var nullableTypeProperty = typeof(MyTestClass).GetProperty("NullableTypeProperty", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsNotNull(nullableTypeProperty);
            var nullableTypePropertyValueGetter = nullableTypeProperty.GetValueGetter();
            Assert.IsNotNull(nullableTypePropertyValueGetter);

            var testClass = new MyTestClass();

            object nullValue = nullableTypePropertyValueGetter(testClass);
            Assert.IsNull(nullValue);

            testClass.NullableTypeProperty = 418;
            object fourOneEightValue = nullableTypePropertyValueGetter(testClass);
            Assert.IsInstanceOfType(fourOneEightValue, typeof(int?));
            Assert.AreEqual(418, fourOneEightValue);
        }
        public void Can_Get_Correct_ValueType_Property_Value()
        {
            var valueTypeProperty = typeof (MyTestClass).GetProperty("ValueTypeProperty", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsNotNull(valueTypeProperty);
            var valueTypePropertyValueGetter = valueTypeProperty.GetValueGetter();
            Assert.IsNotNull(valueTypePropertyValueGetter);
            
            var testClass = new MyTestClass();

            object zeroValue = valueTypePropertyValueGetter(testClass);
            Assert.IsInstanceOfType(zeroValue, typeof (int));
            Assert.AreEqual(0, zeroValue);

            testClass.ValueTypeProperty = 418;
            object fourOneEightValue = valueTypePropertyValueGetter(testClass);
            Assert.IsInstanceOfType(fourOneEightValue, typeof(int));
            Assert.AreEqual(418, fourOneEightValue);
        }
Esempio n. 40
0
        public void TestFeatureFromClass()
        {
            var testObject = new MyTestClass()
                {
                    BooleanProperty = true,
                    DateTimeProperty = DateTime.Now,
                    DoubleProperty = 1.2345d,
                    EnumProperty = MyTestEnum.Value1,
                    IntProperty = -1,
                    StringProperty = "Hello, GeoJSON !"
                };

            Feature.Feature feature = new Feature.Feature(new Point(new GeographicPosition(10, 10)), testObject);

            Assert.IsNotNull(feature.Properties);
            Assert.IsTrue(feature.Properties.Count > 1);
            Assert.AreEqual(feature.Properties.Count, 6);

        }
Esempio n. 41
0
        public void Ctor_Can_Add_Properties_Using_Object()
        {
            var properties = new MyTestClass
            {
                BooleanProperty = true,
                DateTimeProperty = DateTime.Now,
                DoubleProperty = 1.2345d,
                EnumProperty = MyTestEnum.Value1,
                IntProperty = -1,
                StringProperty = "Hello, GeoJSON !"
            };

            Net.Feature.Feature feature = new Net.Feature.Feature(new Point(new GeographicPosition(10, 10)), properties);

            Assert.IsNotNull(feature.Properties);
            Assert.IsTrue(feature.Properties.Count > 1);
            Assert.AreEqual(feature.Properties.Count, 6);
        }
Esempio n. 42
0
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest3()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest3: Calling indexof method ,T is user define type. ");
        try
        {
            IList<MyTestClass> myList = new List<MyTestClass>();
            MyTestClass myTest = null;
            for (int i = 1; i <= 10; i++)
            {
                myTest = new MyTestClass();
                myTest.ID = i;
                myList.Add(myTest);
            }
            int expectValue = 9;
            int actualValue = myList.IndexOf(myTest);
            if (actualValue != expectValue)
            {
                TestLibrary.TestFramework.LogError("003.1", "Calling IndexOf method return a value correctly.");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e);
            retVal = false;
        }
        return retVal;
    }
            protected override void Context()
            {
                base.Context();

                Target = new MyTestClass();
            }
            protected override void Context()
            {
                base.Context();

                Source = new MyTestClass();
            }
            protected override void Context()
            {
                base.Context();

                Source = Builder<MyTestClass>.CreateNew().Build();
                Target = new MyTestClass
                {
                    Age = Source.Age,
                    Name = Source.Name,
                };
            }
 public void Init()
 {
     rangeClass = new MyTestClass();
     int32Info = rangeClass.GetType().GetProperty("Int32Value");
     Assert.IsNotNull(int32Info);
     doubleInfo = rangeClass.GetType().GetProperty("DoubleValue");
     Assert.IsNotNull(doubleInfo);
     floatInfo = rangeClass.GetType().GetProperty("FloatValue");
     Assert.IsNotNull(floatInfo);
     charInfo = rangeClass.GetType().GetProperty("CharValue");
     Assert.IsNotNull(charInfo);
     stringInfo = rangeClass.GetType().GetProperty("StringValue");
     Assert.IsNotNull(stringInfo);
 }
Esempio n. 47
0
        public void Feature_Equals_GetHashCode_Contract_Properties_Of_Objects()
        {
            // order of keys should not matter

            var leftProp = new MyTestClass
            {
                StringProperty = "Hello, GeoJSON !",
                EnumProperty = MyTestEnum.Value1,
                IntProperty = -1,
                BooleanProperty = true,
                DateTimeProperty = DateTime.Now,
                DoubleProperty = 1.2345d
            };

            var left = new Net.Feature.Feature(new Point(new GeographicPosition(10, 10)), leftProp);

            var rightProp = new MyTestClass
            {
                BooleanProperty = true,
                DateTimeProperty = DateTime.Now,
                DoubleProperty = 1.2345d,
                EnumProperty = MyTestEnum.Value1,
                IntProperty = -1,
                StringProperty = "Hello, GeoJSON !"
            };

            var right = new Net.Feature.Feature(new Point(new GeographicPosition(10, 10)), rightProp);

            Assert_Are_Equal(left, right);
        }