Exemplo n.º 1
0
        public void ReadOnlyTest()
        {
            // Arrange
            _currencies.Add(_gold, 10f);
            _currencies.isReadOnly = true;

            // Act
            var canAdd    = _currencies.CanAdd(_gold, 1f);
            var add       = _currencies.Add(_gold, 2);
            var canRemove = _currencies.CanRemove(_gold, 1f);
            var remove    = _currencies.Remove(_gold, 2);

            _currencies.Clear();
            _currencies.Set(_gold, 1f);

            // Assert
            Assert.AreEqual(Errors.CollectionIsReadOnly, canAdd.error);
            Assert.AreEqual(Errors.CollectionIsReadOnly, add.error);
            Assert.AreEqual(Errors.CollectionIsReadOnly, canRemove.error);
            Assert.AreEqual(Errors.CollectionIsReadOnly, remove.error);

            Assert.IsFalse(canAdd.result);
            Assert.IsFalse(add.result);
            Assert.IsFalse(canRemove.result);
            Assert.IsFalse(remove.result);

            Assert.AreEqual(10f, _currencies.GetAmount(_gold));
        }