コード例 #1
0
        public void TwoWayDictionary_Add_WhenKeyValueAdded_AddingValueKeyShouldFail()
        {
            int    i = 1;
            string s = "one";

            _sut.Add(i, s);

            _sut.Invoking(x => x.Add(i, "anything else"))
            .Should().Throw <ArgumentException>()
            .WithMessage($"The collection already contains an item for {i}.");

            _sut.Invoking(x => x.Add(666, s))
            .Should().Throw <ArgumentException>()
            .WithMessage($"The collection already contains an item for {s}.");
        }