Exemplo n.º 1
0
        public void Equalsによる同一確認(string bindStr1, string bindStr2, bool expected)
        {
            //setUp
            var sut = new BindAddr(bindStr1);
            var target = (bindStr2 == null) ? null : new BindAddr(bindStr2);

            //exercise
            var actual = sut.Equals(target);
            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemplo n.º 2
0
        public void CheckCompetitionによる競合があるかどうかの確認(string bindStr1, string bindStr2, bool expected)
        {
            //setUp
            var sut = new BindAddr(bindStr1);
            var target = (bindStr2 == null) ? null : new BindAddr(bindStr2);

            //exercise
            var actual = sut.CheckCompetition(target);
            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemplo n.º 3
0
        public void CreateOneBindで生成される数の確認(string bindStr, ProtocolKind protocolKind, int count, string firstOneBind)
        {
            //stUp
            var sut = new BindAddr(bindStr);
            var expected = count;

            //exercise
            var ar = sut.CreateOneBind(protocolKind);
            var actual = ar.Length;
            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemplo n.º 4
0
        //競合があるかどうかの確認
        public bool CheckCompetition(BindAddr b)
        {
            CheckInitialise();
            bool v4Competition = false; //V4競合の可能性
            bool v6Competition = false; //V6競合の可能性
            switch (BindStyle){
                case BindStyle.V46Dual:
                    if (b.BindStyle == BindStyle.V46Dual){
                        v4Competition = true;
                        v6Competition = true;
                    }
                    else if (b.BindStyle == BindStyle.V4Only){
                        v4Competition = true;
                    }
                    else{
                        v6Competition = true;
                    }
                    break;
                case BindStyle.V4Only:
                    if (b.BindStyle != BindStyle.V6Only){
                        v4Competition = true;
                    }
                    break;
                case BindStyle.V6Only:
                    if (b.BindStyle != BindStyle.V4Only){
                        v6Competition = true;
                    }
                    break;
            }

            //V4競合の可能性がある場合
            if (v4Competition){
                //どちらかがANYの場合は、競合している
                if (IpV4.Any || b.IpV4.Any)
                    return true;
                if (IpV4 == b.IpV4)
                    return true;
            }
            //V6競合の可能性がある場合
            if (v6Competition){
                //どちらかがANYの場合は、競合している
                if (IpV6.Any || b.IpV6.Any)
                    return true;
                if (IpV6 == b.IpV6)
                    return true;
            }
            return false;
        }
Exemplo n.º 5
0
 public void パラメータBindStyle_ipv4_ipv6でnewしたBindAddrオブジェクトをToStringで確認する(
     BindStyle bindStyle, string ipV4, string ipV6, string expected)
 {
     //setUp
     var sut = new BindAddr(bindStyle, new Ip(ipV4), new Ip(ipV6));
     //exercise
     var actual = sut.ToString();
     //verify
     Assert.That(actual, Is.EqualTo(expected));
 }
Exemplo n.º 6
0
 public void Totostringによる確認()
 {
     //setUp
     var expected = "V4Only,INADDR_ANY,IN6ADDR_ANY_INIT";
     var sut = new BindAddr();
     //exercise
     var actual = sut.ToString();
     //verify
     Assert.That(actual, Is.EqualTo(expected));
 }
Exemplo n.º 7
0
 public void 文字列でnewしたBindAddrオブジェクトをToStringで確認する(string bindStr, string expected)
 {
     //setUp
     var sut = new BindAddr(bindStr);
     //exercise
     var actual = sut.ToString();
     //verify
     Assert.That(actual, Is.EqualTo(expected));
 }
Exemplo n.º 8
0
        //競合があるかどうかの確認
        public bool CheckCompetition(BindAddr b)
        {
            CheckInitialise();
            bool v4Competition = false; //V4競合の可能性
            bool v6Competition = false; //V6競合の可能性

            switch (BindStyle)
            {
            case BindStyle.V46Dual:
                if (b.BindStyle == BindStyle.V46Dual)
                {
                    v4Competition = true;
                    v6Competition = true;
                }
                else if (b.BindStyle == BindStyle.V4Only)
                {
                    v4Competition = true;
                }
                else
                {
                    v6Competition = true;
                }
                break;

            case BindStyle.V4Only:
                if (b.BindStyle != BindStyle.V6Only)
                {
                    v4Competition = true;
                }
                break;

            case BindStyle.V6Only:
                if (b.BindStyle != BindStyle.V4Only)
                {
                    v6Competition = true;
                }
                break;
            }

            //V4競合の可能性がある場合
            if (v4Competition)
            {
                //どちらかがANYの場合は、競合している
                if (IpV4.Any || b.IpV4.Any)
                {
                    return(true);
                }
                if (IpV4 == b.IpV4)
                {
                    return(true);
                }
            }
            //V6競合の可能性がある場合
            if (v6Competition)
            {
                //どちらかがANYの場合は、競合している
                if (IpV6.Any || b.IpV6.Any)
                {
                    return(true);
                }
                if (IpV6 == b.IpV6)
                {
                    return(true);
                }
            }
            return(false);
        }