当前位置: 首页>>代码示例>>C#>>正文


C# Address.Equals方法代码示例

本文整理汇总了C#中Address.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Address.Equals方法的具体用法?C# Address.Equals怎么用?C# Address.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Address的用法示例。


在下文中一共展示了Address.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestEquals_ShouldBeTrue

 public void TestEquals_ShouldBeTrue()
 {
     var address = new Address(_street, _postalCode, _city, _country);
     Assert.IsTrue(
         address.Equals(_address)
     );
 }
开发者ID:dawiddominiak,项目名称:BakeryManagementSystem,代码行数:7,代码来源:AddressTest.cs

示例2: IdenticalDataEqualsIsTrueTest

      public void IdenticalDataEqualsIsTrueTest()
      {
         //Arrange
         var address1 = new Address("streetLine1", "streetLine2", "city", "zipcode");
         var address2 = new Address("streetLine1", "streetLine2", "city", "zipcode");

         //Act
         var resultEquals = address1.Equals(address2);
         var resultEqualsSimetric = address2.Equals(address1);
         var resultEqualsOnThis = address1.Equals(address1);

         //Assert
         Assert.IsTrue(resultEquals);
         Assert.IsTrue(resultEqualsSimetric);
         Assert.IsTrue(resultEqualsOnThis);
      }
开发者ID:MyLobin,项目名称:NLayerAppV2,代码行数:16,代码来源:ValueObjectTests.cs

示例3: TestEquals_ShouldBeFalse

 public void TestEquals_ShouldBeFalse()
 {
     var address = new Address("Other street 200/1", _postalCode, _city, _country);
     Assert.IsFalse(
         address.Equals(_address)
     );
 }
开发者ID:dawiddominiak,项目名称:BakeryManagementSystem,代码行数:7,代码来源:AddressTest.cs

示例4: AddressShouldBeAValueObject

        public void AddressShouldBeAValueObject()
        {
            var address1 = new Address(76873274, "Rua", "Juriti", "Setor 02", "Ariquemes", "Rondônia");
            var address2 = new Address(76873274, "Rua", "Juriti", "Setor 02", "Ariquemes", "Rondônia");

            Assert.IsTrue(address1.Equals(address2));
        }
开发者ID:WiLLStenico,项目名称:AddressAPI,代码行数:7,代码来源:AddressTests.cs

示例5: AddressEquality

        public void AddressEquality()
        {
            Dictionary<string, object> address = new Dictionary<string, object> { { "Existence", "Exists" }, { "Published", false } };
            var ii0 = new Address(typeof(HeaderContent), "abc&def");
            var ii1 = new Address(typeof(HeaderContent), "abc&def");
            var ii2 = new Address(typeof(RestaurantContent), "abc&def");
            var ii3 = new Address(typeof(HeaderContent), "abc");

            Assert.IsTrue(ii0.Equals(ii1), ".Equals true");
            Assert.IsTrue(ii0 == ii1, "== true");
            Assert.IsFalse(ii0.Equals(ii2), ".Equals false by type");
            Assert.IsFalse(ii0 == ii2, "== false by different val");
            Assert.IsFalse(ii1.Equals(ii3), ".Equals false by missing key");
            Assert.IsFalse(ii1 == ii3, "== false by missing key");

            Assert.IsFalse(ii0.GetHashCode() == ii2.GetHashCode(), "hash code by type");
            Assert.IsFalse(ii1.GetHashCode() == ii3.GetHashCode(), "hash code by missing key");
        }
开发者ID:jamesej,项目名称:lynicon,代码行数:18,代码来源:AddressTests.cs

示例6: CorreiosRepositoryGetAddressShouldBeReturnAValidAddress

        public void CorreiosRepositoryGetAddressShouldBeReturnAValidAddress()
        {
            var expected = new Address(76873274, "Rua", "Juriti", "Setor 02", "Ariquemes", "RO");

            var repository = new CorreiosRepository();

            var address = repository.GetAddress(76873274);

            Assert.IsInstanceOfType(address, typeof(Address));
            Assert.IsTrue(expected.Equals(address));
        }
开发者ID:WiLLStenico,项目名称:AddressAPI,代码行数:11,代码来源:CorreiosRepositoryTests.cs

示例7: Address_equals_working_test

        public void Address_equals_working_test()
        {
            Address address = new Address()
            {
                Country = "asd",
                Id = 1,
                StreetAddress = "asda",
                ZipCode = "1234"
            }; Address address2 = new Address()
            {
                Country = "asd",
                Id = 1,
                StreetAddress = "asda",
                ZipCode = "1234"
            };

            Assert.IsTrue(address.Equals(address2));
            address2.Country = "changed";
            Assert.IsFalse(address2.Equals(address));
            Assert.IsFalse(address2.Equals(null));
        }
开发者ID:nordtorp95,项目名称:ExamProject2015,代码行数:21,代码来源:AddressTest.cs

示例8: DiferentDataEqualsIsFalseTest

        public void DiferentDataEqualsIsFalseTest()
        {
            //Arrange
            Address address1 = new Address("streetLine1", "streetLine2", "city", "zipcode");
            Address address2 = new Address("streetLine2", "streetLine1", "city", "zipcode");

            //Act
            bool result = address1.Equals(address2);
            bool resultSimetric = address2.Equals(address1);

            //Assert
            Assert.IsFalse(result);
            Assert.IsFalse(resultSimetric);
        }
开发者ID:gabrielsimas,项目名称:MicrosoftNLayerApp,代码行数:14,代码来源:ValueObjectTests.cs

示例9: SameReferenceEqualsTrueTest

        public void SameReferenceEqualsTrueTest()
        {
            //Arrange
            Address address1 = new Address("streetLine1", null, null, "streetLine1");
            Address address2 = address1;

            //Act
            if (!address1.Equals(address2))
                Assert.Fail();

            if (!(address1 == address2))
                Assert.Fail();
        }
开发者ID:gabrielsimas,项目名称:MicrosoftNLayerApp,代码行数:13,代码来源:ValueObjectTests.cs

示例10: SameDataInDiferentPropertiesIsEqualsFalseTest

        public void SameDataInDiferentPropertiesIsEqualsFalseTest()
        {
            //Arrange
            Address address1 = new Address("streetLine1", "streetLine2",null, null);
            Address address2 = new Address("streetLine2", "streetLine1", null, null);

            //Act
            bool result = address1.Equals(address2);

            //Assert
            Assert.IsFalse(result);
        }
开发者ID:gabrielsimas,项目名称:MicrosoftNLayerApp,代码行数:12,代码来源:ValueObjectTests.cs

示例11: AllowLockTransfer

    /**
     * Allow if we are transfering to a LinkProtocolState or ConnectionPacketHandler
     * Note this method does not change anything, if the transfer is done, it
     * is done by the ConnectionTable while it holds its lock.
     */
    public bool AllowLockTransfer(Address a, string contype, ILinkLocker l) {
      bool allow = false;
      bool hold_lock = (a.Equals( _target_lock ) && contype == _contype);
      if( false == hold_lock ) {
        //We don't even hold this lock!
        throw new Exception(
                            String.Format("{2} asked to transfer a lock({0}) we don't hold: ({1})",
                                          a, _target_lock, this));
      }
      if( l is Linker ) {
        //Never transfer to another linker:
      }
      else if ( l is ConnectionPacketHandler.CphState ) {
      /**
       * The ConnectionPacketHandler only locks when it
       * has actually received a packet.  This is a "bird in the
       * hand" situation, however, if both sides in the double
       * link case transfer the lock, then we have accomplished
       * nothing.
       *
       * There is a specific case to worry about: the case of
       * a firewall, where only one node can contact the other.
       * In this case, it may be very difficult to connect if
       * we don't eventually transfer the lock to the
       * ConnectionPacketHandler.  In the case of bi-directional
       * connectivity, we only transfer the lock if the
       * address we are locking is greater than our own (which
       * clearly cannot be true for both sides).
       * 
       * To handle the firewall case, we keep count of how
       * many times we have been asked to transfer the lock.  On
       * the third time we are asked, we assume we are in the firewall
       * case and we allow the transfer, this is just a hueristic.
       */
        int reqs = Interlocked.Increment(ref _cph_transfer_requests);
        if ( (reqs >= 3 ) || ( a.CompareTo( LocalNode.Address ) > 0) ) {
          allow = true;
        }
      }
      else if( l is LinkProtocolState ) {
        LinkProtocolState lps = (LinkProtocolState)l;
        /**
         * Or Transfer the lock to a LinkProtocolState if:
         * 1) We created this LinkProtocolState
         * 2) The LinkProtocolState has received a packet
         */
        if( (lps.Linker == this ) && ( lps.LinkMessageReply != null ) ) {
          allow = true;
        }
      }
#if LINK_DEBUG
      if (BU.ProtocolLog.LinkDebug.Enabled) {
	  BU.ProtocolLog.Write(BU.ProtocolLog.LinkDebug,
                            String.Format("{0}: Linker({1}) {2}: transfering lock on {3} to {4}",
                              _local_n.Address, _lid, (_target_lock == null), a, l));
      }
#endif
      return allow;
    }
开发者ID:johnynek,项目名称:brunet,代码行数:64,代码来源:Linker.cs

示例12: TryReleaseLock

 public void TryReleaseLock(Address addr, string transactionID)
 {
     if (addr.Equals (IsisSystem.GetMyAddress ())) {
         Transaction trans = FileServerComm.getInstance().transManager.removeAndGetTransaction(transactionID);
         if(null != trans){
             trans.signalTransactionEnd();
         }
     }
 }
开发者ID:piyushmh,项目名称:cloud-filesystem,代码行数:9,代码来源:FileOperation.cs

示例13: AllowLockTransfer

 /**
  * Note that a LinkProtocolState only gets a lock *AFTER* it has
  * received a LinkMessageReply.  Prior to that, the Linker that
  * created it holds the lock (if the _linker.Target is not null).
  *
  * So, given that we are being asked to transfer a lock, we must
  * have already gotten our LinkMessageReply set, or we wouldn't
  * hold the lock in the first place.
  *
  * So, we only transfer locks to other Linkers when we are finished
  * since us holding a lock means we have already head some
  * communication from the other side.
  * 
  * Since the CT.Lock and CT.Unlock methods can't be called when this
  * is being called, we know that _target_lock won't change during
  * this method.
  */
 public bool AllowLockTransfer(Address a, string contype, ILinkLocker l)
 {
   bool hold_lock = (a.Equals( _target_lock ) && contype == _contype);
   if( false == hold_lock ) {
     //This is a bug.
     throw new Exception(String.Format("We don't hold the lock: {0}", a));
   }
   if( (l is Linker) && IsFinished ) {
     return true;
   }
   return false;
 }
开发者ID:bakriy,项目名称:brunet,代码行数:29,代码来源:LinkProtocolState.cs

示例14: getHighSeqnoSeen

        /// <summary>
        /// Returns the highest seqno seen from sender. 
        /// </summary>
        /// <param name="sender">The address for which the highest seqno is to be retrieved</param>
        /// <returns>Highest seen sequence number</returns>
        long getHighSeqnoSeen(Address sender)
        {
            NakReceiverWindow  win;
            long               ret=0;

            if(sender == null)
            {
                if(Trace.trace)
                    Trace.error("NAKACK.getHighSeqnoSeen()", "sender is null");
                return ret;
            }
            if(sender.Equals(local_addr))
                return seqno-1;

            win=(NakReceiverWindow)received_msgs[sender];
            if(win == null)
            {
                if(Trace.trace)
                    Trace.error("NAKACK.getHighSeqnoSeen()", "sender " + sender + " not found in received_msgs");
                return ret;
            }
            ret=win.getHighestReceived();
            return ret;
        }
开发者ID:curasystems,项目名称:externals,代码行数:29,代码来源:NAKACK.cs

示例15: CreateInstance

 /**
  * Factory method to reduce memory allocations by caching
  * commonly used NodeInfo objects
  */
 public static NodeInfo CreateInstance(Address a) {
   //Read some of the least significant bytes out,
   //AHAddress all have last bit 0, so we skip the last byte which
   //will have less entropy
   MemBlock mb = a.ToMemBlock();
   ushort idx = (ushort)NumberSerializer.ReadShort(mb, Address.MemSize - 3);
   NodeInfo ni = _mb_cache[idx];
   if( ni != null ) {
     if (a.Equals(ni._address)) {
       return ni;
     }
   }
   ni = new NodeInfo(a);
   _mb_cache[idx] = ni;
   return ni;
 }
开发者ID:twchoi,项目名称:brunet,代码行数:20,代码来源:NodeInfo.cs


注:本文中的Address.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。