Exemplo n.º 1
0
  public static void Main( string[] args )
  {
    // Create instance and call template method
    ConcreteClass c = new ConcreteClass();
    c.TemplateMethod();

  }
Exemplo n.º 2
0
        public void DuckedTypeCannotGetPrivateProperty()
        {
            var a = new ConcreteClass();
            var duck = a.Duck<IProtectedInterface>();

            duck.ProtectedData = "test";
        }
Exemplo n.º 3
0
        public void TestOAuth2Scopes()
        {
            var scopes = new JsonDictionary();

            scopes.Add("https://www.example.com/auth/one", new Scope()
            {
                ID = "https://www.example.com/auth/one"
            });
            scopes.Add("https://www.example.com/auth/two", new Scope()
            {
                ID = "https://www.example.com/auth/two"
            });
            var oauth2 = new JsonDictionary()
            {
                { "scopes", scopes }
            };
            var auth = new JsonDictionary()
            {
                { "oauth2", oauth2 }
            };
            var dict = new JsonDictionary()
            {
                { "auth", auth }, { "name", "TestName" }, { "version", "v1" }
            };

            IService impl = new ConcreteClass(dict);

            Assert.IsNotNull(impl.Scopes);
            Assert.AreEqual(2, impl.Scopes.Count);
            Assert.IsTrue(impl.Scopes.ContainsKey("https://www.example.com/auth/one"));
            Assert.IsTrue(impl.Scopes.ContainsKey("https://www.example.com/auth/two"));
        }
Exemplo n.º 4
0
        public void TestSimpleGetters()
        {
            var dict = new JsonDictionary();

            dict.Add("name", "TestName");
            dict.Add("version", "v1");
            dict.Add("description", "Test Description");
            dict.Add("documentationLink", "https://www.google.com/");
            dict.Add("features", new List <object> {
                "feature1", "feature2"
            });
            dict.Add("labels", new List <object> {
                "label1", "label2"
            });
            dict.Add("id", "TestId");
            dict.Add("title", "Test API");

            IService impl = new ConcreteClass(dict);

            Assert.AreEqual("Test Description", impl.Description);
            Assert.AreEqual("https://www.google.com/", impl.DocumentationLink);
            MoreAsserts.ContentsEqualAndInOrder(new List <string> {
                "feature1", "feature2"
            }, impl.Features);
            MoreAsserts.ContentsEqualAndInOrder(new List <string> {
                "label1", "label2"
            }, impl.Labels);
            Assert.AreEqual("TestId", impl.Id);
            Assert.AreEqual("Test API", impl.Title);
        }
Exemplo n.º 5
0
        public void Test_Patch_ConcreteClass()
        {
            var instance = new Harmony("special-case-1");

            Assert.NotNull(instance, "instance");
            var processor = instance.CreateClassProcessor(typeof(ConcreteClass_Patch));

            Assert.NotNull(processor, "processor");

            var someStruct1 = new ConcreteClass().Method("test", new AnotherStruct());

            Assert.True(someStruct1.accepted, "someStruct1.accepted");

            TestTools.Log($"Patching ConcreteClass_Patch start");
            var replacements = processor.Patch();

            Assert.NotNull(replacements, "replacements");
            Assert.AreEqual(1, replacements.Count);
            TestTools.Log($"Patching ConcreteClass_Patch done");

            TestTools.Log($"Running patched ConcreteClass_Patch start");
            var someStruct2 = new ConcreteClass().Method("test", new AnotherStruct());

            Assert.True(someStruct2.accepted, "someStruct2.accepted");
            TestTools.Log($"Running patched ConcreteClass_Patch done");
        }
Exemplo n.º 6
0
        public void DuckedTypeCannotGetPrivateEvent()
        {
            var a = new ConcreteClass();
            var duck = a.Duck<IProtectedInterfaceWithEvent>();

            duck.ProtectedEvent += (sender, args) => args.ToString();
        }
Exemplo n.º 7
0
        public void TestCommonParameters()
        {
            const string testJson =
                @"{
            'fields': {
                'type': 'string',
                'description': 'Selector specifying which fields to include in a partial response.',
                'location': 'query'
            },
            'prettyPrint': {
                'type': 'boolean',
                'description': 'Returns response with indentations and line breaks.',
                'default': 'true',
                'location': 'query'
            },
            }";
            var paramDict = Google.Apis.Json.JsonReader.Parse(testJson.Replace('\'', '\"')) as JsonDictionary;
            var dict      = new JsonDictionary()
            {
                { "parameters", paramDict },
                { "name", "TestName" },
                { "version", "v1" }
            };
            var impl = new ConcreteClass(dict);

            Assert.That(impl.Parameters.Count, Is.EqualTo(2));
            Assert.That(impl.Parameters.Keys,
                        Is.EquivalentTo(new string[] { "fields", "prettyPrint" }));
            var prettyPrint = impl.Parameters["prettyPrint"];

            Assert.That(prettyPrint.Description,
                        Is.EqualTo("Returns response with indentations and line breaks."));
            Assert.That(prettyPrint.ValueType, Is.EqualTo("boolean"));
        }
Exemplo n.º 8
0
        public void DuckedTypeCannotGetPrivateMethod()
        {
            var a = new ConcreteClass();
            var duck = a.Duck<IProtectedInterfaceWithMethod>();

            duck.ProtectedMethod();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            ConcreteClass instance = new ConcreteClass();

            instance.Method();

            Console.ReadKey();
        }
Exemplo n.º 10
0
            static void Main(string[] args)
            {
                IInterface II = new ConcreteClass();

                II.FunctionA();
                II.FunctionB();
                II.FunctionC();
            }
Exemplo n.º 11
0
        public void DuckedTypeCanGetProperty()
        {
            var a = new ConcreteClass();
            var duck = a.Duck<ITest>();
            a.Tuple = new Tuple<string, int>("test", 1);

            Assert.AreEqual(a.Tuple.Item1, duck.Tuple.Item1);
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            Abstract a = new ConcreteClass();
            Abstract b = new ConcreteClassB();

            a.TemplateMethod();
            b.TemplateMethod();
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            ConcreteClass concreteClass = new ConcreteClass();

            //Upcast needed
            IInterface1 interface1 = concreteClass as IInterface1;

            interface1.Method();
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            AbstractClass instance = new ConcreteClass();

            instance.Method();

            // Delay
            Console.ReadKey();
        }
Exemplo n.º 15
0
        public void GetTheSameConcreteClassTwiceFromCreate()
        {
            AutoMocker <ConcreteClass> autoMocker = createAutoMocker <ConcreteClass>();
            ConcreteClass concreteClass           = autoMocker.ClassUnderTest;

            Assert.AreSame(concreteClass, autoMocker.ClassUnderTest);
            Assert.AreSame(concreteClass, autoMocker.ClassUnderTest);
            Assert.AreSame(concreteClass, autoMocker.ClassUnderTest);
        }
Exemplo n.º 16
0
        static void Main()
        {
            ConcreteClass instance = new ConcreteClass();

            instance.Method();

            // Delay.
            Console.ReadKey();
        }
Exemplo n.º 17
0
        public void UseTheAutoMockerToStartUpTheConcreteClassAsAPartialMockAndSetTheNameMethodUp()
        {
            AutoMocker <ConcreteClass> autoMocker = createAutoMocker <ConcreteClass>();

            autoMocker.PartialMockTheClassUnderTest();
            ConcreteClass concreteClass = autoMocker.ClassUnderTest;

            setExpectation(concreteClass, x => x.Name, "Max");
            concreteClass.Name.ShouldEqual("Max");
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            ConcreteClass concreteClass = new ConcreteClass();

            concreteClass.Method();

            IInterface1 interface1 = concreteClass as IInterface1;

            interface1.Method();
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            IInterface II = new ConcreteClass();

            II.FunctionA();
            II.FunctionB();
            II.FunctionC();
            Console.Read();
            Console.WriteLine("Hello World!");
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            AbstractClassA inst = new ConcreteClass();

            inst.OperationA();
            //inst.OperationB(); // Недоступен, т.к. мы приводились к А, т.е. мы инкапсулировали ОперэйшнВ
            AbstractClassB instance = new ConcreteClass();

            instance.OperationA();
            instance.OperationB();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Calculate Structural Class based on PN-EN 1992-1-1 Table 4.3N
        /// </summary>
        public ConcreteCoverOutput CalculateStructuralClass(ConcreteCoverInput inputData)
        {
            this.inputData = inputData;

            ExposureClass exposureClass = ConvertStringToExposureClass(this.inputData.ExposureClass);
            ConcreteClass concreteClass = ConvertStringToConcreteClass(this.inputData.ConcreteClass);

            this.outputData.StructuralClass = this.inputData.BaseStructuralClass;

            // Check Exposure Class
            if (exposureClass == ExposureClass.X0 || exposureClass == ExposureClass.XC1 ||
                exposureClass == ExposureClass.XC2 || exposureClass == ExposureClass.XC3 ||
                exposureClass == ExposureClass.XC4 || exposureClass == ExposureClass.XD1 ||
                exposureClass == ExposureClass.XD2 || exposureClass == ExposureClass.XS1 ||
                exposureClass == ExposureClass.XD3 || exposureClass == ExposureClass.XS2 ||
                exposureClass == ExposureClass.XS3
                )
            {
                // Modification based on Design Working Life of 100 years
                if (this.inputData.DesignWorkingLifeOf100Years)
                {
                    //this.StructuralClass = (StructuralClass)((int)StructuralClass + 2).Clamp((int)StructuralClass.S1, (int)StructuralClass.S6);
                    this.outputData.StructuralClass = ((int)ConvertStringToStructuralClass(this.outputData.StructuralClass) + 2).ToString();
                }

                // Modification based on Concrete Class and Exposure Class
                if ((concreteClass >= ConcreteClass.C30_37 && (exposureClass == ExposureClass.X0 || exposureClass == ExposureClass.XC1)) ||
                    (concreteClass >= ConcreteClass.C35_45 && (exposureClass == ExposureClass.XC2 || exposureClass == ExposureClass.XC3)) ||
                    (concreteClass >= ConcreteClass.C40_50 && (exposureClass == ExposureClass.XC4 || exposureClass == ExposureClass.XD1 || exposureClass == ExposureClass.XD2 || exposureClass == ExposureClass.XS1)) ||
                    (concreteClass >= ConcreteClass.C45_55 && (exposureClass == ExposureClass.XD3 || exposureClass == ExposureClass.XS2 || exposureClass == ExposureClass.XS3)))
                {
                    //this.StructuralClass = (StructuralClass)((int)StructuralClass - 1).Clamp((int)StructuralClass.S1, (int)StructuralClass.S6);
                    this.outputData.StructuralClass = ((int)ConvertStringToStructuralClass(this.outputData.StructuralClass) - 1).ToString();
                }

                // Modification based on Member With Slab Geometry
                if (this.inputData.MemberWithSlabGeometry)
                {
                    //this.StructuralClass = (StructuralClass)((int)StructuralClass - 1).Clamp((int)StructuralClass.S1, (int)StructuralClass.S6);
                    this.outputData.StructuralClass = ((int)ConvertStringToStructuralClass(this.outputData.StructuralClass) - 1).ToString();
                }

                // Modification based on Member With Slab Geometry
                if (this.inputData.SpecialQualityControlOfTheConcreteProductionEnsured)
                {
                    //this.StructuralClass = (StructuralClass)((int)StructuralClass - 1).Clamp((int)StructuralClass.S1, (int)StructuralClass.S6);
                    this.outputData.StructuralClass = ((int)ConvertStringToStructuralClass(this.outputData.StructuralClass) - 1).ToString();
                }
            }

            this.outputData.StructuralClass = ((int)ConvertStringToStructuralClass(this.outputData.StructuralClass)).Clamp((int)StructuralClass.S1, (int)StructuralClass.S6).ToString();

            return(this.outputData);
        }
Exemplo n.º 22
0
        public void TestCommonParametersMissing()
        {
            var paramDict = new JsonDictionary();
            var dict      = new JsonDictionary()
            {
                { "name", "TestName" }, { "version", "v1" }
            };
            var impl = new ConcreteClass(dict);

            Assert.That(impl.Parameters, Is.Not.Null);
            Assert.That(impl.Parameters.Count, Is.EqualTo(0));
        }
Exemplo n.º 23
0
        public static void TestGetTypeInAbstract()
        {
            ConcreteClass test = new ConcreteClass();

            Assert.AreEqual(
                "Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+ConcreteClass",
                test.TypeProp,
                "Property query for instance:abstract class returns the expected class name.");
            Assert.AreEqual(
                "Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+ConcreteClass",
                test.TypeMethod(),
                "Method query returns the expected class name.");
        }
Exemplo n.º 24
0
        public void TheAutoMockerOptionallyPushesInMocksInReplayModeToAllowForAAAsyntax()
        {
            // This sets up a Rhino Auto Mocker in the Arrange, Act, Assert mode
            var autoMocker = new RhinoAutoMocker <ConcreteClass>(MockMode.AAA);

            // Act in the test
            ConcreteClass @class = autoMocker.ClassUnderTest;

            @class.CallService();

            // This retrieves the mock object for IMockedService
            autoMocker.Get <IMockedService>().AssertWasCalled(s => s.Go());
        }
Exemplo n.º 25
0
        //模板模式调用
        public static void GetTemplate()
        {
            //现在想吃绿色的面,猪肉大葱馅的饺子
            AbstractClass fan = new ConcreteClass();

            fan.EatDumplings();

            Console.WriteLine();

            //过了段时间,我开始想吃橙色面的,韭菜鸡蛋馅的饺子
            fan = new ConcreteClass2();
            fan.EatDumplings();
            Console.Read();
        }
Exemplo n.º 26
0
        public void TheAutoMockerPushesInMocksForAllOfTheConstructorArgumentsForAPartialMock()
        {
            AutoMocker <ConcreteClass> autoMocker = createAutoMocker <ConcreteClass>();

            var service  = autoMocker.Get <IMockedService>();
            var service2 = autoMocker.Get <IMockedService2>();
            var service3 = autoMocker.Get <IMockedService3>();

            autoMocker.PartialMockTheClassUnderTest();
            ConcreteClass concreteClass = autoMocker.ClassUnderTest;

            Assert.AreSame(service, concreteClass.Service);
            Assert.AreSame(service2, concreteClass.Service2);
            Assert.AreSame(service3, concreteClass.Service3);
        }
Exemplo n.º 27
0
            static void Main(string[] args)
            {
                //现在想吃绿色面的,猪肉大葱馅的饺子
                AbstractClass fan = new ConcreteClass();

                fan.EatDumplings();

                Console.WriteLine();
                //过了段时间,我开始想吃橙色面的,韭菜鸡蛋馅的饺子
                fan = new ConcreteClass2();
                fan.EatDumplings();


                Console.Read();
            }
Exemplo n.º 28
0
        public void Custom_Id_In_Interface()
        {
            var mapper = new BsonMapper();

            var obj = new ConcreteClass {
                CustomId = "myid", Name = "myname"
            };
            var doc = mapper.Serialize(obj) as BsonDocument;

            doc["_id"].Should().NotBeNull();
            doc["_id"].Should().Be("myid");
            doc["CustomName"].Should().NotBe(BsonValue.Null);
            doc["CustomName"].Should().Be("myname");
            doc["Name"].Should().Be(BsonValue.Null);
            doc.Keys.ExpectCount(2);
        }
Exemplo n.º 29
0
        public void TheAutoMockerPushesInMocksAndAPreBuiltStubForAllOfTheConstructorArguments()
        {
            AutoMocker <ConcreteClass> autoMocker = createAutoMocker <ConcreteClass>();
            var stub = new StubService();

            autoMocker.Inject <IMockedService>(stub);

            var service2 = autoMocker.Get <IMockedService2>();
            var service3 = autoMocker.Get <IMockedService3>();

            ConcreteClass concreteClass = autoMocker.ClassUnderTest;

            Assert.AreSame(stub, concreteClass.Service);
            Assert.AreSame(service2, concreteClass.Service2);
            Assert.AreSame(service3, concreteClass.Service3);
        }
Exemplo n.º 30
0
            static void Main()
            {
                ConcreteClass instance = new ConcreteClass();

                instance.Method();

                IInterface1 instance1 = instance as IInterface1;

                instance1.Method();

                IInterface2 instance2 = instance as IInterface2;

                instance2.Method();

                // Delay.
                Console.ReadKey();
            }
        public void AbstractClassTableName()
        {
            ActiveRecordStarter.ResetInitializationFlag();
            Assert.IsTrue(NHibernate.Cfg.Environment.UseReflectionOptimizer);

            ActiveRecordStarter.Initialize(GetConfigSource(),
                                           typeof(AbstractClass<>),
                                           typeof(ConcreteClass));
            Assert.IsFalse(NHibernate.Cfg.Environment.UseReflectionOptimizer);

            Recreate();

            ConcreteClass c = new ConcreteClass();

            c.Save();

            Assert.IsTrue(ConcreteClass.FindAll().Length == 1);
        }
		public void AbstractClassTableName()
		{
			ActiveRecordStarter.ResetInitializationFlag();
			Assert.IsTrue(NHibernate.Cfg.Environment.UseReflectionOptimizer);

			ActiveRecordStarter.Initialize(GetConfigSource(),
										   typeof(AbstractClass<>),
										   typeof(ConcreteClass));
			Assert.IsFalse(NHibernate.Cfg.Environment.UseReflectionOptimizer);

			Recreate();

			ConcreteClass c = new ConcreteClass();

			c.Save();

			Assert.IsTrue(ConcreteClass.FindAll().Length == 1);
		}
Exemplo n.º 33
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Implementing generic interfaces.***\n");
            //Using 'int' type
            GenericInterface <int> concreteInt = new ConcreteClass <int>();
            int myInt = concreteInt.GenericMethod(5);

            Console.WriteLine($"The value stored in myInt is : {myInt}");
            concreteInt.NonGenericMethod();

            //Using 'string' type now
            GenericInterface <string> concreteString = new ConcreteClass <string>();
            string myStr = concreteString.GenericMethod("Hello Reader");

            Console.WriteLine($"The value stored in myStr is : {myInt}");
            concreteString.NonGenericMethod();

            Console.ReadKey();
        }
Exemplo n.º 34
0
        public void TestBaseUri()
        {
            ConcreteClass instance = (ConcreteClass)CreateV1Service();

            instance.BasePath  = "/test/";
            instance.ServerUrl = "https://www.test.value/";
            Assert.AreEqual("https://www.test.value/test/", instance.BaseUri.ToString());

            instance.BasePath  = "test/";
            instance.ServerUrl = "https://www.test.value/";
            Assert.AreEqual("https://www.test.value/test/", instance.BaseUri.ToString());

            instance.BasePath  = "/test/";
            instance.ServerUrl = "https://www.test.value";
            Assert.AreEqual("https://www.test.value/test/", instance.BaseUri.ToString());

            instance.BasePath  = "test/";
            instance.ServerUrl = "https://www.test.value";
            Assert.AreEqual("https://www.test.value/test/", instance.BaseUri.ToString());

            // Mono's Uri class strips double forward slashes so this test will not work.
            // Only run for MS.Net
            if (Google.Apis.Util.Utilities.IsMonoRuntime() == false)
            {
                instance.BasePath  = "//test/";
                instance.ServerUrl = "https://www.test.value";
                Assert.AreEqual("https://www.test.value//test/", instance.BaseUri.ToString());

                instance.BasePath  = "//test/";
                instance.ServerUrl = "https://www.test.value/";
                Assert.AreEqual("https://www.test.value//test/", instance.BaseUri.ToString());

                instance.BasePath  = "test/";
                instance.ServerUrl = "https://www.test.value//";
                Assert.AreEqual("https://www.test.value//test/", instance.BaseUri.ToString());

                instance.BasePath  = "/test//";
                instance.ServerUrl = "https://www.test.value/";
                Assert.AreEqual("https://www.test.value/test//", instance.BaseUri.ToString());
            }
        }
Exemplo n.º 35
0
        public static void TestGetTypeInSuperClass()
        {
            ConcreteClass test = new ConcreteClass();

            Assert.AreEqual(
                "Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+ConcreteClass",
                test.TypeProp,
                "Property query for instance:abstract class returns the expected class name.");
            Assert.AreEqual(
                "Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+ConcreteClass",
                test.TypeMethod(),
                "Method query returns the expected class name.");

            SuperClass sup = new SuperClass();

            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SuperClass",
                            sup.TypeProp,
                            "Property query for direct instance of super class returns the expected name.");
            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SuperClass",
                            sup.TypeMethod(),
                            "Method query for direct instance of super class returns the expected name.");

            SubClass sub = new SubClass();

            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SubClass",
                            sub.TypeProp,
                            "Property query for instance of sub class returns the expected name.");
            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SubClass",
                            sub.TypeMethod(),
                            "Method query for instance of sub class returns the expected name.");

            SuperClass subCast = (SuperClass)sub;

            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SubClass",
                            subCast.TypeProp,
                            "Property query for cast instance of super class returns the expected name.");
            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SubClass",
                            subCast.TypeMethod(),
                            "Method query for cast instance of super class returns the expected name.");
        }
Exemplo n.º 36
0
        public void TestMethodsOnService()
        {
            var testMethod = new JsonDictionary();

            testMethod.Add("id", "service.testMethod");
            testMethod.Add("path", "service/testMethod");
            testMethod.Add("httpMethod", "GET");
            var methods = new JsonDictionary()
            {
                { "testMethod", testMethod }
            };
            var dict = new JsonDictionary()
            {
                { "methods", methods }, { "name", "TestName" }, { "version", "v1" }
            };

            IService impl = new ConcreteClass(dict);

            Assert.IsNotNull(impl.Methods);
            Assert.AreEqual(1, impl.Methods.Count);
            Assert.AreEqual("testMethod", impl.Methods["testMethod"].Name);
        }
Exemplo n.º 37
0
        public void TestOAuth2Scopes()
        {
            var scopes = new JsonDictionary();
            scopes.Add("https://www.example.com/auth/one", new Scope() { ID = "https://www.example.com/auth/one" });
            scopes.Add("https://www.example.com/auth/two", new Scope() { ID = "https://www.example.com/auth/two" });
            var oauth2 = new JsonDictionary() { { "scopes", scopes } };
            var auth = new JsonDictionary() { { "oauth2", oauth2 } };
            var dict = new JsonDictionary() { { "auth", auth }, { "name", "TestName" }, { "version", "v1" } };

            IService impl = new ConcreteClass(dict);
            Assert.IsNotNull(impl.Scopes);
            Assert.AreEqual(2, impl.Scopes.Count);
            Assert.IsTrue(impl.Scopes.ContainsKey("https://www.example.com/auth/one"));
            Assert.IsTrue(impl.Scopes.ContainsKey("https://www.example.com/auth/two"));
        }
Exemplo n.º 38
0
 public void DuckedTypeCanAddAndRemoveEventHandler()
 {
     var a = new ConcreteClass();
     var duck = a.Duck<ITest>();
     duck.TestEvent += DuckOnTestEvent;
     duck.TestEvent -= DuckOnTestEvent;
 }
		public static void SetDesignPattern(ConcreteClass element, DesignPattern newDesignPattern)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ConcreteClassDomainRoleId, newDesignPattern);
		}
Exemplo n.º 40
0
 public void DuckedTypeCallNonReturnMethodWithParameters()
 {
     var a = new ConcreteClass();
     var duck = a.Duck<ITest>();
     duck.Temp("");
 }
Exemplo n.º 41
0
        public void DuckedTypeIsInstanceOfInterface()
        {
            var duck = new ConcreteClass().Duck<ITest>();

            Assert.IsInstanceOfType(duck, typeof(ITest));
        }
Exemplo n.º 42
0
 public void DuckedTypeCallNonReturnGenericMethod()
 {
     var a = new ConcreteClass();
     var duck = a.Duck<ITest>();
     duck.Temp<string>();
 }
Exemplo n.º 43
0
 public void DuckedTypeCallReturnMethod()
 {
     var a = new ConcreteClass();
     var duck = a.Duck<ITest>();
     duck.ATemp();
 }
		public static DesignPattern GetDesignPattern(ConcreteClass element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, ConcreteClassDomainRoleId) as DesignPattern;
		}
Exemplo n.º 45
0
        public void TestSimpleGetters()
        {
            var dict = new JsonDictionary();
            dict.Add("name", "TestName");
            dict.Add("version", "v1");
            dict.Add("description", "Test Description");
            dict.Add("documentationLink", "https://www.google.com/");
            dict.Add("features", new List<object>{ "feature1", "feature2" });
            dict.Add("labels", new List<object>{ "label1", "label2" });
            dict.Add("id", "TestId");
            dict.Add("title", "Test API");

            IService impl = new ConcreteClass(dict);
            Assert.AreEqual("Test Description", impl.Description);
            Assert.AreEqual("https://www.google.com/", impl.DocumentationLink);
            MoreAsserts.ContentsEqualAndInOrder(new List<string> { "feature1", "feature2" }, impl.Features);
            MoreAsserts.ContentsEqualAndInOrder(new List<string> { "label1", "label2" }, impl.Labels);
            Assert.AreEqual("TestId", impl.Id);
            Assert.AreEqual("Test API", impl.Title);
        }
 public AmbiguousConstructorsTestClass(ConcreteClass class1, IDummy dummy1)
 {
 }
Exemplo n.º 47
0
        public void TestMethodsOnService()
        {
            var testMethod = new JsonDictionary();
            testMethod.Add("id", "service.testMethod");
            testMethod.Add("path", "service/testMethod");
            testMethod.Add("httpMethod", "GET");
            var methods = new JsonDictionary() { { "testMethod", testMethod } };
            var dict = new JsonDictionary() { { "methods", methods }, { "name", "TestName" }, { "version", "v1" } };

            IService impl = new ConcreteClass(dict);
            Assert.IsNotNull(impl.Methods);
            Assert.AreEqual(1, impl.Methods.Count);
            Assert.AreEqual("testMethod", impl.Methods["testMethod"].Name);
        }
		public void AbstractClassTableName()
		{
			ActiveRecordStarter.ResetInitializationFlag();

			ActiveRecordStarter.Initialize(GetConfigSource(),
										   typeof(AbstractClass<>),
										   typeof(ConcreteClass));
			Recreate();

			ConcreteClass c = new ConcreteClass();

			c.Save();

			Assert.IsTrue(ConcreteClass.FindAll().Length == 1);
		}
Exemplo n.º 49
0
        public void TestCommonParametersMissing()
        {
            var paramDict = new JsonDictionary();
            var dict = new JsonDictionary() { { "name", "TestName" }, { "version", "v1" } };
            var impl = new ConcreteClass(dict);

            Assert.That(impl.Parameters, Is.Not.Null);
            Assert.That(impl.Parameters.Count, Is.EqualTo(0));
        }
Exemplo n.º 50
0
 public DefaultValue()
 {
     ConcreteClass = new ConcreteClass();
 }
Exemplo n.º 51
0
 public void TestCommonParameters()
 {
     const string testJson =
     @"{
     'fields': {
         'type': 'string',
         'description': 'Selector specifying which fields to include in a partial response.',
         'location': 'query'
     },
     'prettyPrint': {
         'type': 'boolean',
         'description': 'Returns response with indentations and line breaks.',
         'default': 'true',
         'location': 'query'
     },
     }";
     var paramDict = Google.Apis.Json.JsonReader.Parse(testJson.Replace('\'', '\"')) as JsonDictionary;
     var dict = new JsonDictionary() { 
         { "parameters", paramDict}, 
         { "name", "TestName" },
         { "version", "v1" } };
     var impl = new ConcreteClass(dict);
     Assert.That(impl.Parameters.Count, Is.EqualTo(2));
     Assert.That(impl.Parameters.Keys, 
         Is.EquivalentTo(new string[] { "fields", "prettyPrint" }));
     var prettyPrint = impl.Parameters["prettyPrint"];
     Assert.That(prettyPrint.Description,
         Is.EqualTo("Returns response with indentations and line breaks."));
     Assert.That(prettyPrint.ValueType, Is.EqualTo("boolean"));
 }
Exemplo n.º 52
0
 public void DuckedTypeCallReturnGenericMethodWithParameters()
 {
     var a = new ConcreteClass();
     var duck = a.Duck<ITest>();
     duck.ATemp<string>("");
 }
Exemplo n.º 53
0
        public void DuckedTypeIsNotNull()
        {
            var duck = new ConcreteClass().Duck<ITest>();

            Assert.IsNotNull(duck);
        }
Exemplo n.º 54
0
 public void DuckedTypeCanAddEventHandler()
 {
     var a = new ConcreteClass();
     var duck = a.Duck<ITest>();
     duck.TestEvent += (sender, args) => { };
 }
		/// <summary>
		/// Constructor
		/// Creates a DesignPatternHasConcreteClasses link in the same Partition as the given DesignPattern
		/// </summary>
		/// <param name="source">DesignPattern to use as the source of the relationship.</param>
		/// <param name="target">ConcreteClass to use as the target of the relationship.</param>
		public DesignPatternHasConcreteClasses(DesignPattern source, ConcreteClass target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(DesignPatternHasConcreteClasses.DesignPatternDomainRoleId, source), new DslModeling::RoleAssignment(DesignPatternHasConcreteClasses.ConcreteClassDomainRoleId, target)}, null)
		{
		}