public void TestProductChannelExclusivityEquals() {
      ProductChannelExclusivity channelExclusivityA = new ProductChannelExclusivity() {
        channelExclusivity = ShoppingProductChannelExclusivity.MULTI_CHANNEL
      };

      ProductChannelExclusivity channelExclusivityB = new ProductChannelExclusivity() {
        channelExclusivity = ShoppingProductChannelExclusivity.MULTI_CHANNEL
      };

      ProductChannelExclusivity channelExclusivityC = new ProductChannelExclusivity() {
        channelExclusivity = ShoppingProductChannelExclusivity.SINGLE_CHANNEL
      };

      ProductChannelExclusivity channelExclusivityD = new ProductChannelExclusivity();
      ProductChannelExclusivity channelExclusivityE = new ProductChannelExclusivity();

      Assert.True(comparer.Equals(channelExclusivityA, channelExclusivityB));
      Assert.False(comparer.Equals(channelExclusivityA, channelExclusivityC));

      //Null value is handled gracefully.
      Assert.False(comparer.Equals(channelExclusivityA, channelExclusivityE));
      Assert.True(comparer.Equals(channelExclusivityD, channelExclusivityE));
    }
    public void TestProductChannelExclusivityGetHashcode() {
      ProductChannelExclusivity channelExclusivityA = new ProductChannelExclusivity() {
        channelExclusivity = ShoppingProductChannelExclusivity.MULTI_CHANNEL
      };

      ProductChannelExclusivity channelExclusivityB = new ProductChannelExclusivity() {
        channelExclusivity = ShoppingProductChannelExclusivity.MULTI_CHANNEL
      };

      ProductChannelExclusivity channelExclusivityC = new ProductChannelExclusivity() {
        channelExclusivity = ShoppingProductChannelExclusivity.SINGLE_CHANNEL
      };

      Assert.AreEqual(comparer.GetHashCode(channelExclusivityA),
          comparer.GetHashCode(channelExclusivityB));
      Assert.AreNotEqual(comparer.GetHashCode(channelExclusivityA),
          comparer.GetHashCode(channelExclusivityC));
    }
コード例 #3
0
    public void TestProductChannelExclusivityEquals() {
      ProductChannelExclusivity channelExclusivityA = new ProductChannelExclusivity() {
        channelExclusivity = ShoppingProductChannelExclusivity.MULTI_CHANNEL
      };

      ProductChannelExclusivity channelExclusivityB =
          ProductDimensions.CreateChannelExclusivity(
              ShoppingProductChannelExclusivity.MULTI_CHANNEL);

      Assert.True(comparer.Equals(channelExclusivityA, channelExclusivityB));

      ProductChannelExclusivity channelExclusivityC = new ProductChannelExclusivity() {
      };

      ProductChannelExclusivity channelExclusivityD = ProductDimensions.CreateChannelExclusivity();

      Assert.True(comparer.Equals(channelExclusivityC, channelExclusivityD));
    }