Exemplo n.º 1
0
        public void ConstructorTest()
        {
            // Test default constructor
            { 
                Trinary trin = new Trinary();

                Assert.AreEqual(False, trin);
            }

            // Test bool constructor
            {
                Trinary trin = new Trinary(true);

                Assert.AreEqual(True, trin);

                trin = new Trinary(false);

                Assert.AreEqual(False, trin);
            }

            // Test bool? constructor
            {
                Trinary trin = new Trinary((bool?)true);

                Assert.AreEqual(True, trin);

                trin = new Trinary((bool?)false);

                Assert.AreEqual(False, trin);

                trin = new Trinary(null);

                Assert.IsTrue(trin.IsUndefined);
            }
        }
Exemplo n.º 2
0
        private Trinary ParseReplyToPrompt(string reply)
        {
            Trinary result   = Trinary.No;
            bool    response = false;

            string pattern = "^(yes|yup|y|yeah)";
            Regex  regex   = new Regex(pattern, RegexOptions.IgnoreCase);

            response = regex.IsMatch(reply);
            if (response)
            {
                result = Trinary.Yes;
            }

            if (!response)
            {
                pattern = "^(no|nope|n|nah)";
                regex   = new Regex(pattern, RegexOptions.IgnoreCase);
                if (!regex.IsMatch(reply))
                {
                    result = Trinary.Unsure;
                }
            }

            return(result);
        }
 public void Input(Trinary value)
 {
     foreach (var branch in ioPaths)
     {
         if (branch.value == value)
         {
             branch.OnActivate.Invoke();
         }
     }
 }
 public void Input(Trinary value)
 {
     foreach (var element in actions)
     {
         if (element.value == value)
         {
             element.OnActivate.Invoke();
         }
     }
 }
Exemplo n.º 5
0
        // * Consider move to different class
        public static float RotationDirection(Trinary clockwise)
        {
            switch (clockwise)
            {
            case Trinary.True: return(1f);

            case Trinary.False: return(-1f);

            default: return(0f);
            }
        }
Exemplo n.º 6
0
        Color GetColorFromResult(Trinary result)
        {
            switch (result)
            {
            case Trinary.True: return(validColor);

            case Trinary.False: return(blockedColor);

            case Trinary.Unknown: return(invalidColor);
            }

            return(invalidColor);
        }
Exemplo n.º 7
0
        public static int CompareTo(this Boolean myBoolean, Trinary myTrinary)
        {
            if (myTrinary == Trinary.FALSE    && myBoolean == false)
                return 0;

            if (myTrinary == Trinary.DELETED  && myBoolean == false)
                return 0;

            if (myTrinary == Trinary.TRUE     && myBoolean == true)
                return 0;

            return 1;
        }
Exemplo n.º 8
0
        public async Task MessageReceivedAsync(IDialogContext ctx, IAwaitable <IMessageActivity> argument)
        {
            var message = await argument;

            switch (this.state)
            {
            case WhoWorkedState.UserPrompted:
                Trinary carryOn = ParseReplyToPrompt(message.Text);
                this.state = WhoWorkedState.UserRepliedToPrompt;
                switch (carryOn)
                {
                case Trinary.Yes:
                    List <string> movieOptions = new List <string>();
                    IEnumerable <Shared.MovieDetails> movies = await GetMovies(GetPeopleList());

                    foreach (var movie in movies)
                    {
                        movieOptions.Add(movie.title);
                    }
                    PromptOptions <string> promptOptions = new PromptOptions <string>(prompt: "Which one?", options: movieOptions);
                    PromptDialog.Choice <string>(ctx, Resume, promptOptions);
                    break;

                case Trinary.No:
                    await ctx.PostAsync("OK, maybe another time.");

                    ctx.Done("");
                    break;

                default:
                    ctx.Done(message.Text);
                    break;
                }
                break;

            default:
                ctx.Wait(MessageReceivedAsync);
                break;
            }
        }
 public void Trinary_11_is_decimal_4()
 {
     Assert.Equal(4, Trinary.ToDecimal("11"));
 }
Exemplo n.º 10
0
 public void SetRandomDirection()
 {
     clockwise = RandomStatics.CoinToss() ? Trinary.True : Trinary.False;
 }
 public void Invalid_word_as_input_returns_0()
 {
     Assert.Equal(0, Trinary.ToDecimal("carrot"));
 }
 public void Trinary_1_is_decimal_1()
 {
     Assert.Equal(1, Trinary.ToDecimal("1"));
 }
 public void Trinary_222_is_decimal_26()
 {
     Assert.Equal(26, Trinary.ToDecimal("222"));
 }
Exemplo n.º 14
0
 public static bool False(this Trinary tri) => (tri == Trinary.False);
Exemplo n.º 15
0
 public static bool True(this Trinary tri) => (tri == Trinary.True);
Exemplo n.º 16
0
        /// <summary>
        /// Шифрование текста комбинация 1
        /// </summary>
        /// <param name="N0"> исходный текст </param>
        /// <returns></returns>
        public static string EnCombo1(string N0)
        {
            List <int> S1(string _N0)
            {
                List <int> code = new List <int>();

                foreach (char i in _N0)
                {
                    code.Add(NT117.indexSymNT117(i));
                }

                return(code);
            }

            List <string> T1(List <int> _S1)
            {
                List <string> S1T1 = new List <string>();

                foreach (int i in _S1)
                {
                    S1T1.Add(Trinary.To3(i));
                }

                return(S1T1);
            }

            List <string> F1(List <string> _T1)
            {
                List <string> _R0 = new List <string>();

                char   c  = '0';
                string b1 = "|";
                string b2;

                char r = 'k';
                int  z = 1;

                foreach (string i in _T1)
                {
                    if (z >= 10)
                    {
                        z++;
                        if (z <= 10)
                        {
                            z = 1;
                        }
                    }

                    foreach (char j in i)
                    {
                        if (c == j)
                        {
                            z++;

                            r = (char)new Random().Next('a', 'z' + z);

                            b1 = b1.Replace(b1[0], r);
                            break;
                        }
                        else
                        {
                            b1 = "|";
                        }
                    }

                    b2 = NT117.symIndex_NT177(Trinary.Back3(i)).ToString();

                    if (b1 != "|")
                    {
                        _R0.Add(b2 + b1);
                    }
                    else
                    {
                        _R0.Add(b2);
                    }
                }

                return(_R0);
            }

            string R0(List <string> _F1)
            {
                string b = "";

                foreach (string i in _F1)
                {
                    b += i;
                }
                return(b);
            }

            return(R0(F1(T1(S1(N0)))));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Дешифрование текста комбинация 1
        /// </summary>
        /// <param name="R0"> исходный текст </param>
        /// <returns></returns>
        public static string DeCombo1(string R0)
        {
            List <int> S1(string _N0)
            {
                List <int> code = new List <int>();

                foreach (char i in _N0)
                {
                    code.Add(NT117.indexSym_NT117(i));
                }

                return(code);
            }

            List <string> T1(List <int> _S1)
            {
                List <string> S1T1 = new List <string>();

                foreach (int i in _S1)
                {
                    S1T1.Add(Trinary.To3(i));
                }

                return(S1T1);
            }

            List <string> F1(List <string> _T1)
            {
                List <string> _N0 = new List <string>();

                int  i_ = 0;
                bool t  = false;

                for (int i = 0; i < _T1.Count;)
                {
                    if (_T1.Count > i)
                    {
                        for (int j = 0; _T1[i].Length > j; j++)
                        {
                            if (_T1[i][j] == '0')
                            {
                                t = true;
                                break;
                            }
                            else
                            {
                                t = false;
                            }
                        }

                        if (t == true)
                        {
                            _N0.Add(_T1[i]);
                            i += 2;
                        }
                        else
                        {
                            _N0.Add(_T1[i]);
                            i++;
                        }
                    }

                    i_++;
                }

                return(_N0);
            }

            string N0(List <string> _F1)
            {
                string n0 = "";

                foreach (string i in _F1)
                {
                    n0 += NT117.symIndexNT177(Trinary.Back3(i)).ToString();
                }

                return(n0);
            }

            return(N0(F1(T1(S1(R0)))));
        }
 public void Trinary_100_is_decimal_9()
 {
     Assert.Equal(9, Trinary.ToDecimal("100"));
 }
 public void Trinary_112_is_decimal_14()
 {
     Assert.Equal(14, Trinary.ToDecimal("112"));
 }
Exemplo n.º 20
0
 public static bool Nonce(this Trinary tri) => (tri == Trinary.Nonce);
 public void Trinary_1122000120_is_decimal_32091()
 {
     Assert.Equal(32091, Trinary.ToDecimal("1122000120"));
 }
Exemplo n.º 22
0
 public TeleportResult(Vector3 cutoffPoint, Trinary success, GameObject surface = null)
 {
     this.cutoffPoint = cutoffPoint;
     this.success     = success;
     this.surface     = surface;
 }
 public void Invalid_trinary_digits_returns_0()
 {
     Assert.Equal(0, Trinary.ToDecimal("1234"));
 }
Exemplo n.º 24
0
 public void Invalid_trinary_is_decimal_0(string invalidValue)
 {
     Assert.That(Trinary.ToDecimal(invalidValue), Is.EqualTo(0));
 }
 public void Invalid_numbers_with_letters_as_input_returns_0()
 {
     Assert.Equal(0, Trinary.ToDecimal("0a1b2c"));
 }
Exemplo n.º 26
0
 public void InputResult(Trinary result)
 {
     success = result == Trinary.True;
 }
Exemplo n.º 27
0
 public int Trinary_converts_to_decimal(string value)
 {
     return(Trinary.ToDecimal(value));
 }
Exemplo n.º 28
0
        public void TypeConverterTest()
        {
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Trinary));

            Assert.IsNotNull(converter);
            Assert.IsInstanceOfType(converter, typeof(TrinaryConverter));

            // Test CanConvertFrom

            Assert.IsTrue(converter.CanConvertFrom(typeof(string)));
            Assert.IsTrue(converter.CanConvertFrom(typeof(bool)));
            Assert.IsTrue(converter.CanConvertFrom(typeof(bool?)));
            Assert.IsTrue(converter.CanConvertFrom(typeof(Trinary)));
            Assert.IsFalse(converter.CanConvertFrom(typeof(TrinaryTest)));

            // Test CanConvertTo

            Assert.IsTrue(converter.CanConvertTo(typeof(string)));
            Assert.IsTrue(converter.CanConvertTo(typeof(bool)));
            Assert.IsTrue(converter.CanConvertTo(typeof(bool?)));
            Assert.IsTrue(converter.CanConvertTo(typeof(Trinary)));
            Assert.IsFalse(converter.CanConvertTo(typeof(TrinaryTest)));

            // Test ConvertFrom(string)

            string test1 = "TruE";

            string test2 = "UNDEfined";

            string test3 = "FALSe";

            object obj = converter.ConvertFrom(test1);

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.AreEqual(True, obj);

            obj = converter.ConvertFrom(test2);

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.IsTrue(((Trinary)obj).IsUndefined);

            obj = converter.ConvertFrom(test3);

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.AreEqual(False, obj);

            // Test ConvertFrom(bool)

            bool bool1 = true;
            bool bool2 = false;

            obj = converter.ConvertFrom(bool1);

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.AreEqual(True, obj);

            obj = converter.ConvertFrom(bool2);

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.AreEqual(False, obj);

            // Test ConvertFrom(bool?)

            bool? nbool1 = true;
            bool? nbool2 = false;

            obj = converter.ConvertFrom(nbool1);

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.AreEqual(True, obj);

            obj = converter.ConvertFrom(nbool2);

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.AreEqual(False, obj);

            //obj = converter.ConvertFrom(nbool3);

            //Assert.IsInstanceOfType(obj, typeof(Trinary));
            //Assert.IsTrue(((Trinary)obj).IsUndefined);

            // Test ConvertFrom(Trinary)

            Trinary test = new Trinary();

            obj = converter.ConvertFrom(test);

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.AreEqual(False, obj);

            // Test ConvertTo(string)

            obj = converter.ConvertTo(True, typeof(string));

            Assert.IsInstanceOfType(obj, typeof(string));
            Assert.AreEqual(TrueString, obj);

            obj = converter.ConvertTo(False, typeof(string));

            Assert.IsInstanceOfType(obj, typeof(string));
            Assert.AreEqual(FalseString, obj);

            obj = converter.ConvertTo(Undefined, typeof(string));

            Assert.IsInstanceOfType(obj, typeof(string));
            Assert.AreEqual(UndefinedString, obj);

            // Test ConvertTo(bool)

            obj = converter.ConvertTo(True, typeof(bool));

            Assert.IsInstanceOfType(obj, typeof(bool));
            Assert.AreEqual(true, obj);

            obj = converter.ConvertTo(False, typeof(bool));

            Assert.IsInstanceOfType(obj, typeof(bool));
            Assert.AreEqual(false, obj);

            // Test ConvertTo(bool?)

            obj = converter.ConvertTo(True, typeof(bool?));

            Assert.IsInstanceOfType(obj, typeof(bool?));
            Assert.AreEqual(true, obj);

            obj = converter.ConvertTo(False, typeof(bool?));

            Assert.IsInstanceOfType(obj, typeof(bool?));
            Assert.AreEqual(false, obj);

            obj = converter.ConvertTo(Undefined, typeof(bool?));

            Assert.IsNull(obj);

            // Test ConvertTo(Trinary)

            obj = converter.ConvertTo(True, typeof(Trinary));

            Assert.IsInstanceOfType(obj, typeof(Trinary));
            Assert.AreEqual(True, obj);
        }
Exemplo n.º 29
0
 public void Trinary_can_convert_formatted_strings()
 {
     Assert.That(Trinary.ToDecimal("011"), Is.EqualTo(4));
 }
 public void Trinary_2_is_decimal_2()
 {
     Assert.Equal(2, Trinary.ToDecimal("2"));
 }
 public void Trinary_10_is_decimal_3()
 {
     Assert.Equal(3, Trinary.ToDecimal("10"));
 }
Exemplo n.º 32
0
 public static BuildLocator WithDimensions(BuildTypeLocator buildType = null,
     UserLocator user = null,
     string agentName = null,
     BuildStatus? status = null,
     bool? personal = null,
     bool? canceled = null,
     Trinary? running = null,
     bool? pinned = null,
     int? maxResults = null,
     int? startIndex = null,
     BuildLocator sinceBuild = null,
     DateTime? sinceDate = null,
     string[] tags = null,
     string branch = null
     )
 {
     return new BuildLocator
                {
                    BuildType = buildType,
                    User = user,
                    AgentName = agentName,
                    Status = status,
                    Personal = personal,
                    Canceled = canceled,
                    Running = running,
                    Pinned = pinned,
                    MaxResults = maxResults,
                    StartIndex = startIndex,
                    SinceBuild = sinceBuild,
                    SinceDate = sinceDate,
                    Tags = tags,
                    Branch = branch
                };
 }