Exemple #1
0
        public void ModType_ApiOptional_ParsedSuccessfully()
        {
            var _modSource = "optional";
            var modSource  = EnumConvert.ToEnum <WebModType>(_modSource);

            modSource.Should().Be(WebModType.Optional);
        }
Exemple #2
0
        public static void EnumConvert_ToEnumOfInt64()
        {
            Assert.Equal(Int64Enum.MinValue, EnumConvert.ToEnum <Int64Enum>(long.MinValue));
            Assert.Equal(Int64Enum.MaxValue, EnumConvert.ToEnum <Int64Enum>(long.MaxValue));

            Assert.Equal(Int64Enum.UInt64MaxValue, EnumConvert.ToEnum <Int64Enum>(ulong.MaxValue));
        }
Exemple #3
0
        public void ModType_ApiClientSide_ParsedSuccessfully()
        {
            var _modSource = "client_side";
            var modSource  = EnumConvert.ToEnum <WebModType>(_modSource);

            modSource.Should().Be(WebModType.ClientSide);
        }
Exemple #4
0
        public void ModType_ApiRequired_ParsedSuccessfully()
        {
            var _modSource = "required";
            var modSource  = EnumConvert.ToEnum <WebModType>(_modSource);

            modSource.Should().Be(WebModType.Required);
        }
        public void ModSource_ApiDirectory_ParsedSuccessfully()
        {
            var _modSource = "directory";
            var modSource  = EnumConvert.ToEnum <WebModSource>(_modSource);

            modSource.Should().Be(WebModSource.Directory);
        }
        public void ModSource_ApiSteamWorkshop_ParsedSuccessfully()
        {
            var _modSource = "steam_workshop";
            var modSource  = EnumConvert.ToEnum <WebModSource>(_modSource);

            modSource.Should().Be(WebModSource.SteamWorkshop);
        }
Exemple #7
0
        public static void EnumConvert_ToEnumOfInt32()
        {
            Assert.Equal(Int32Enum.MinValue, EnumConvert.ToEnum <Int32Enum>(int.MinValue));
            Assert.Equal(Int32Enum.MaxValue, EnumConvert.ToEnum <Int32Enum>(int.MaxValue));

            Assert.Equal(Int32Enum.Int64MinValue, EnumConvert.ToEnum <Int32Enum>(long.MinValue));
            Assert.Equal(Int32Enum.UInt32MaxValue, EnumConvert.ToEnum <Int32Enum>(uint.MaxValue));
        }
Exemple #8
0
        public static void EnumConvert_ToEnumOfInt16()
        {
            Assert.Equal(Int16Enum.MinValue, EnumConvert.ToEnum <Int16Enum>(short.MinValue));
            Assert.Equal(Int16Enum.MaxValue, EnumConvert.ToEnum <Int16Enum>(short.MaxValue));

            Assert.Equal(Int16Enum.Int32MinValue, EnumConvert.ToEnum <Int16Enum>(int.MinValue));
            Assert.Equal(Int16Enum.UInt16MaxValue, EnumConvert.ToEnum <Int16Enum>(ushort.MaxValue));
        }
Exemple #9
0
        public static void EnumConvert_ToEnumOfSByte()
        {
            Assert.Equal(SByteEnum.MinValue, EnumConvert.ToEnum <SByteEnum>(sbyte.MinValue));
            Assert.Equal(SByteEnum.MaxValue, EnumConvert.ToEnum <SByteEnum>(sbyte.MaxValue));

            Assert.Equal(SByteEnum.Int16MinValue, EnumConvert.ToEnum <SByteEnum>(short.MinValue));
            Assert.Equal(SByteEnum.ByteMaxValue, EnumConvert.ToEnum <SByteEnum>(byte.MaxValue));
        }
Exemple #10
0
        public static void EnumConvert_ToEnumOfByte()
        {
            Assert.Equal(ByteEnum.MinValue, EnumConvert.ToEnum <ByteEnum>(byte.MinValue));
            Assert.Equal(ByteEnum.MaxValue, EnumConvert.ToEnum <ByteEnum>(byte.MaxValue));

            Assert.Equal(ByteEnum.SByteMinValue, EnumConvert.ToEnum <ByteEnum>(sbyte.MinValue));
            Assert.Equal(ByteEnum.UInt16MaxValue, EnumConvert.ToEnum <ByteEnum>(ushort.MaxValue));
        }
        public async Task TestGraphQLClient()
        {
            TestEnv.LogTestMethodStart();
            ServerResponse resp;
            string         thingName;
            var            query1 = "query ($id: Int) { getThing(id: $id) {name kind theFlags} }";
            var            queryM = "query { things {name} }";
            var            vars   = new TDict()
            {
                { "id", 3 }
            };

            // Post requests
            TestEnv.LogTestDescr("Testing Post requests");
            // single thing with query parameter
            resp = await TestEnv.Client.PostAsync(query1, vars);

            resp.EnsureNoErrors();
            var thing = resp.data.getThing;

            thingName = thing.name;
            Assert.AreEqual("Name3", thingName);
            var thingKind = EnumConvert.ToEnum <ThingKind>(thing.kind);

            Assert.AreEqual(ThingKind.KindThree, thingKind, "Invalid kind field value.");
            var flags = EnumConvert.ToEnum <TheFlags>(thing.theFlags);

            Assert.AreEqual(TheFlags.FlagOne | TheFlags.FlagTwo, flags, "Invalid flags field value");

            // list of things
            resp = await TestEnv.Client.PostAsync(queryM, vars);

            resp.EnsureNoErrors();
            thingName = resp.data.things[1].name;
            Assert.AreEqual("Name2", thingName);

            TestEnv.LogTestDescr("Testing Get requests");
            // single thing with query parameter
            resp = await TestEnv.Client.GetAsync(query1, vars);

            resp.EnsureNoErrors();
            thingName = resp.data.getThing.name;
            Assert.AreEqual("Name3", thingName);

            // list of things
            resp = await TestEnv.Client.GetAsync(queryM, vars);

            resp.EnsureNoErrors();
            thingName = resp.data.things[1].name;
            Assert.AreEqual("Name2", thingName);

            TestEnv.LogTestDescr("Testing queries with errors");
            resp = await TestEnv.Client.PostAsync(query1 + " ABCD ", vars);

            var errs = resp.Errors;

            Assert.IsTrue(errs.Count > 0, "Expected syntax error");
        }
Exemple #12
0
        private IDbDataParameter[] CreateParameters(Dictionary <string, DBParameter> paramObj)
        {
            List <IDbDataParameter> list = new List <IDbDataParameter>();

            foreach (KeyValuePair <string, DBParameter> kv in paramObj)
            {
                IDbDataParameter npgsql = GetDataParameter();
                npgsql.ParameterName = kv.Key.Trim().StartsWith("@") ? kv.Key : "@" + kv.Key;
                npgsql.Value         = kv.Value;
                npgsql.DbType        = EnumConvert.ToEnum <DbType>(kv.Value.DbType);
                npgsql.Direction     = EnumConvert.ToEnum <ParameterDirection>(kv.Value.ParameterDirection);
                list.Add(npgsql);
            }
            return(list.ToArray());
        }
Exemple #13
0
        public void ToEnumTest()
        {
            char target = 'A';
            ActiveInactiveType result = EnumConvert <ActiveInactiveType> .ToEnum(target);

            Assert.IsTrue(result == ActiveInactiveType.Active);

            result = EnumConvert <ActiveInactiveType> .ToEnum(Convert.ToInt32(target));

            Assert.IsTrue(result == ActiveInactiveType.Active);

            target = 'I';
            result = EnumConvert <ActiveInactiveType> .ToEnum(target);

            Assert.IsTrue(result == ActiveInactiveType.Inactive);

            result = EnumConvert <ActiveInactiveType> .ToEnum(Convert.ToInt32(target));

            Assert.IsTrue(result == ActiveInactiveType.Inactive);
        }
Exemple #14
0
 public static void EnumConvert_NonEnum()
 {
     Assert.Throws <InvalidCastException>(() => EnumConvert.ToEnum <int>(0));
     Assert.Throws <InvalidCastException>(() => EnumConvert.ToByte(0));
 }