public void Success_CanCreateBasicException()
        {
            var exception = new GildedRoseException();

            // We'll check the object, but really what counts is that no exception has been generated
            Assert.IsNotNull(exception);
        }
        public void Success_CanSetMessage()
        {
            // Setup
            const string message = "My error message";

            // Execution
            var exception = new GildedRoseException(message);

            // Assert
            Assert.AreEqual(message, exception.Message);
        }
        public void Success_CanSetMessageAndInnerException()
        {
            // Setup
            const string message        = "My error message";
            var          innerException = new InvalidOperationException("My message ");

            // Execution
            var exception = new GildedRoseException(message, innerException);

            // Assert
            Assert.AreEqual(message, exception.Message);
            Assert.AreEqual(innerException, exception.InnerException);
        }
Example #4
0
        public void Failure_FactoryThrowsGildedRoseException()
        {
            // Setup
            var item = new Item("NewItem", 1, 3, QualityStrategy.Stable, ShelfLifeStrategy.Stable);
            var qualityFactoryMock = new Mock <IQualityAlgorithmFactory>();
            var expectedException  = new GildedRoseException();

            qualityFactoryMock.Setup(f => f.Create(It.IsAny <QualityStrategy>()))
            .Throws(expectedException);
            var factory = new QualityPipelineFactory(qualityFactoryMock.Object, null);

            // Execution and assert
            // We'd expect this to result in the original exception being rethrown
            var theException = Assert.ThrowsException <GildedRoseException>(() => factory.CreatePipeline(item));

            Assert.AreEqual(expectedException, theException);
        }