public void ThrowExceptionIfCantGenerateUniqueValues() { var factoryMock = new Mock<IFactory<bool>>(); var factory = new UniqueFactory<bool>(factoryMock.Object); factoryMock.Setup(m => m.Generate()).Returns(true); factory.Generate(); factoryMock.Setup(m => m.Generate()).Returns(true); Assert.Throws<NoUniqueValueException>(() => factory.Generate()); }
public void CanGenerateUniqueValues() { var factoryMock = new Mock<IFactory<int>>(); var factory = new UniqueFactory<int>(factoryMock.Object); int i = 1; factoryMock.Setup(m => m.Generate()).Returns(() => i++); Assert.DoesNotThrow(()=>factory.Generate()); Assert.DoesNotThrow(() => factory.Generate()); Assert.DoesNotThrow(() => factory.Generate()); }