Exemplo n.º 1
0
    public static int Main(string [] args)
    {
        DayOfWeek?e = DayOfWeek.Monday;
        TestThing t = new TestThing();

        return(t.SetEnum("hi", e));
    }
        public async Task SerializesCorrectly()
        {
            var obj            = new TestThing();
            var serialisedJson = await SerializeAndGetJsonStringAsync(obj);

            await Verifier.VerifyJson(serialisedJson);
        }
        private void AssertSequentialTestThingProperties(TestThing testThing)
        {
            AssertPopulatedTestThingProperties(testThing);

            string json = JsonConvert.SerializeObject(testThing);

            json.Should().Be(_testThingJson);
        }
Exemplo n.º 4
0
        public void Test_Passing_Null_PropertyInfo_Throws_Exception()
        {
            // ARRANGE
            TestThing thing = new TestThing();

            // ACT
            _ = ((PropertyInfo)null) !.GetValueAsString(thing);
        }
Exemplo n.º 5
0
    static void Main(string[] args)
    {
        var item       = new object();
        var test_thing = new TestThing <object>();

        test_thing.SomeMethod("woohoo", item);
        test_thing.SomeMethod("woohoo", item, item);
        Console.ReadLine();
    }
Exemplo n.º 6
0
        public void ReadValues()
        {
            TestThing       thing = new TestThing();
            ReflectedObject root  = new ReflectedObject(thing);

            Assert.AreEqual(root["x"].Value, 1f);
            Assert.AreEqual(root["y"].Value, 2f);
            Assert.AreEqual(root["z"].Value, 3f);
        }
Exemplo n.º 7
0
        public void ChangeFlagIsNotSetWhenSameReferenceValueAssigned()
        {
            TestThing           test     = new TestThing();
            SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThing), test);

            Assert.IsFalse(property.Changed);
            property.Value = test;
            Assert.IsFalse(property.Changed);
        }
        public void GivenRemoteQueryWhenFiltersAppliedThenShouldRetainResultContext()
        {
            var things        = TestThing.GetThings(100);
            var remoteContext = new RemoteContext(dbContextType, dbSet);
            var queryable     = things.AsRemoteQueryable(remoteContext).Where(t => t.Id.Contains("a") && t.IsActive).OrderBy(t => t.Value).Skip(2).Take(10);
            var remote        = queryable as IRemoteQuery;

            Assert.Same(remoteContext, remote.CustomProvider.Context);
        }
        public void GivenRemoteQueryExecutionShouldInterceptToEmpty()
        {
            var things        = TestThing.GetThings(100);
            var remoteContext = new RemoteContext(dbContextType, dbSet);
            var queryable     = things.AsRemoteQueryable(remoteContext).OrderBy(t => t.Value).Skip(2).Take(10);
            var result        = queryable.ToList();

            Assert.Empty(result);
        }
    public override void OnInspectorGUI()
    {
        TestThing test = target as TestThing;

        if (test == null)
        {
            return;
        }
        var textureSet = test.textureSet;

        if (GUILayout.Button("Red"))
        {
            int           index = textureSet.CreateTexture(128, 128);
            var           rta   = textureSet.GetRenderTextureAsset(index);
            RenderTexture rt    = rta.GetRenderTexture();
            RenderTexture old   = RenderTexture.active;
            RenderTexture.active = rt;
            GL.Clear(false, true, new Color(1.0f, 0.0f, 0.0f, 1.0f));
            RenderTexture.active = old;
            EditorUtility.SetDirty(rta);
            Debug.Log("Created red texture " + index);
        }

        if (GUILayout.Button("Green"))
        {
            int           index = textureSet.CreateTexture(128, 128);
            var           rta   = textureSet.GetRenderTextureAsset(index);
            RenderTexture rt    = rta.GetRenderTexture();
            RenderTexture old   = RenderTexture.active;
            RenderTexture.active = rt;
            GL.Clear(false, true, new Color(0.0f, 1.0f, 0.0f, 1.0f));
            RenderTexture.active = old;
            EditorUtility.SetDirty(rta);
            Debug.Log("Created green texture " + index);
        }

        if (GUILayout.Button("Blue"))
        {
            int           index = textureSet.CreateTexture(128, 128);
            var           rta   = textureSet.GetRenderTextureAsset(index);
            RenderTexture rt    = rta.GetRenderTexture();
            RenderTexture old   = RenderTexture.active;
            RenderTexture.active = rt;
            GL.Clear(false, true, new Color(0.0f, 0.0f, 1.0f, 1.0f));
            RenderTexture.active = old;
            EditorUtility.SetDirty(rta);
            Debug.Log("Created blue texture " + index);
        }

        EditorGUILayout.TextField("Textures: " + textureSet.textureCount);

        for (int x = 0; x < textureSet.textureCount; x++)
        {
            GUILayout.Label(textureSet.GetRenderTexture(x));
        }
    }
Exemplo n.º 11
0
        private async void BtnPost_Click(object sender, EventArgs e)
        {
            TestThing obj = new TestThing
            {
                Foo1 = "Bar1",
                Foo2 = "Bar2"
            };

            await MgrHTTP.HTTPPost(obj);
        }
Exemplo n.º 12
0
        public void ChangeFlagIsFlippedWhenNewValueIsAssigned()
        {
            TestThing           test1    = new TestThing();
            TestThing           test2    = new TestThing();
            SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThing), test1);

            Assert.IsFalse(property.Changed);
            property.Value = test2;
            Assert.IsTrue(property.Changed);
        }
Exemplo n.º 13
0
        public void ValueCanBeSet()
        {
            TestThing           thing1   = new TestThing();
            TestThing           thing2   = new TestThing();
            SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThing), thing1);

            Assert.AreEqual(property.Value, thing1);
            property.Value = thing2;
            Assert.AreEqual(property.Value, thing2);
        }
Exemplo n.º 14
0
        public void WriteValues()
        {
            TestThing       thing = new TestThing();
            ReflectedObject root  = new ReflectedObject(thing);

            root["x"].Value = 4f;
            root["y"].Value = 5f;
            Assert.AreEqual(root["x"].Value, 4f);
            Assert.AreEqual(root["y"].Value, 5f);
            Assert.AreEqual(root["z"].Value, 3f);
        }
        public void Populater_Populate_should_populate_with_sequential_values()
        {
            var testThing = new TestThing();

            _populater.Populate(testThing);

            using (new AssertionScope())
            {
                AssertSequentialTestThingProperties(testThing);
            }
        }
        public void Populater_PopulateWithRandomValues_should_populate_with_random_values()
        {
            var testThing = new TestThing();

            _populater.PopulateWithRandomValues(testThing);

            using (new AssertionScope())
            {
                AssertPopulatedTestThingProperties(testThing);
            }
        }
Exemplo n.º 17
0
        public void ChangedIsSetWhenUpdatingValue()
        {
            TestThing           thing1   = new TestThing();
            TestThing           thing2   = new TestThing();
            SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThing), thing1);

            Assert.AreEqual(property.Value, thing1);
            Assert.IsFalse(property.Changed);
            property.Value = thing2;
            Assert.AreEqual(property.Value, thing2);
            Assert.IsTrue(property.Changed);
        }
Exemplo n.º 18
0
        public void Test_Passing_Null_Object_Throws_Exception()
        {
            // ARRANGE
            TestThing thing = new TestThing();

            Type         type         = thing.GetType();
            PropertyInfo propertyInfo = type.GetProperties()
                                        .Single(p => p.Name == nameof(TestThing.MyPropertySomething));

            // ACT
            _ = propertyInfo.GetValueAsString(null !);
        }
Exemplo n.º 19
0
        public void ItAdds10and5()
        {
            //Arrange
            var a = 10;
            var b = 5;
            var expectedResult = a + b;
            var myClass        = new TestThing();

            //Act
            var result = myClass.ItAddsStuff(a, b);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 20
0
        public void CloneIncludeSameServices()
        {
            var obj = new TestThing();

            var collection = new MauiServiceCollection();

            collection.AddSingleton(obj);
            var services = new MauiFactory(collection);

            var first  = new MauiContext(services);
            var second = new MauiContext(first.Services);

            Assert.Same(obj, second.Services.GetService <TestThing>());
        }
Exemplo n.º 21
0
        public void ReturningTheCorrectIntegerForFunMethod()
        {
            //Arrange
            var a = 25;
            var b = 10;
            var expectedResult = a - b;
            var myClass        = new TestThing();

            //Act
            var result = myClass.ForFunMethod(a, b);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 22
0
        public void Test_Read_Object_Returns_Its_ToString()
        {
            // ARRANGE
            TestThing thing = new TestThing();

            Type         type         = thing.GetType();
            PropertyInfo propertyInfo = type.GetProperties()
                                        .Single(p => p.Name == nameof(TestThing.MyPropertySomething));

            // ACT
            string result = propertyInfo.GetValueAsString(thing);

            // ASSERT
            Assert.AreEqual("My To String", result);
        }
Exemplo n.º 23
0
        public void Test_Read_Null_Value_Returns_Empty_String()
        {
            // ARRANGE
            TestThing thing = new TestThing();

            Type         type         = thing.GetType();
            PropertyInfo propertyInfo = type.GetProperties()
                                        .Single(p => p.Name == nameof(TestThing.MyPropertyNullableLong));

            // ACT
            string result = propertyInfo.GetValueAsString(thing);

            // ASSERT
            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 24
0
        public void Test_Read_Numeric_Value_As_String()
        {
            // ARRANGE
            TestThing thing = new TestThing();

            Type         type         = thing.GetType();
            PropertyInfo propertyInfo = type.GetProperties()
                                        .Single(p => p.Name == nameof(TestThing.MyPropertyLong));

            // ACT
            string result = propertyInfo.GetValueAsString(thing);

            // ASSERT
            Assert.AreEqual("1", result);
        }
Exemplo n.º 25
0
        public void AddSpecificInstanceOverridesBase()
        {
            var baseObj = new TestThing();

            var collection = new MauiServiceCollection();

            collection.AddSingleton(baseObj);
            var services = new MauiFactory(collection);

            var specificObj = new TestThing();
            var context     = new MauiContext(services);

            context.AddSpecific <TestThing>(specificObj);

            Assert.Same(specificObj, context.Services.GetService <TestThing>());
        }
        public void Can_combine_WithDependency_parameter_spec_and_registration_parameter_spec()
        {
            var container = new Container();

            container.Register <TestParameter>(
                made: Parameters.Of.Type <string>(serviceKey: "someSetting"),
                reuse: Reuse.Singleton);

            container.Register <TestThing>();
            container.RegisterInstance("in scope", serviceKey: "someSetting");

            var z = new TestThing();
            var t = container.WithDependencies(Parameters.Of.Type(_ => z))
                    .Resolve <TestParameter>();

            Assert.AreSame(z, t.Thing);
            Assert.AreEqual("in scope", t.Setting);
        }
        private void AssertPopulatedTestThingProperties(TestThing testThing)
        {
            testThing.DateTime1.Should().NotBe(DateTime.MinValue);
            testThing.Decimal1.Should().NotBe(0);
            testThing.Decimal2.Should().NotBe(0);
            testThing.Int1.Should().NotBe(0);
            testThing.Int2.Should().NotBe(0);
            testThing.NullableDateTime.Should().NotBeNull().And.NotBe(DateTime.MinValue);
            testThing.String1.Should().NotBeNullOrWhiteSpace();
            testThing.String2.Should().NotBeNullOrWhiteSpace();

            AssertPopulatedTestChildThingProperties(testThing.ChildThing);

            testThing.ChildrenThings.Should().NotBeNull().And.HaveCountGreaterOrEqualTo(1);

            foreach (TestChildThing child in testThing.ChildrenThings)
            {
                AssertPopulatedTestChildThingProperties(child);
            }
        }
        public void Can_combine_WithDependency_property_spec_and_registration_property_spec()
        {
            var container = new Container();

            container.Register <TestParameter3>(
                made: PropertiesAndFields.Of.Name(nameof(TestParameter3.Test), serviceKey: "someSetting"),
                reuse: Reuse.Singleton);

            container.RegisterInstance("instance", serviceKey: "someSetting");

            var thing = new TestThing();

            var t = container
                    .WithDependencies(
                propertiesAndFields: PropertiesAndFields.Of.Name(nameof(TestParameter3.Thing), _ => thing))
                    .Resolve <TestParameter3>();

            Assert.AreSame(thing, t.Thing);
            Assert.AreEqual("instance", t.Test);
        }
Exemplo n.º 29
0
	public static int Main (string [] args)
	{
		DayOfWeek? e = DayOfWeek.Monday;
		TestThing t = new TestThing ();
		return t.SetEnum ("hi", e);
	}
 public TestParameter(TestThing thing, string setting)
 {
     Thing   = thing;
     Setting = setting;
 }
Exemplo n.º 31
0
            static void DoAdd(MauiContext ctx)
            {
                var specificObj = new TestThing();

                ctx.AddSpecific <TestThing>(specificObj);
            }