public void SutIsCommand()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     // Exercise system
     var sut = fixture.CreateAnonymous<CurrencyUpdateCommand>();
     // Verify outcome
     Assert.IsInstanceOfType(sut, typeof(ICommand));
     // Teardown
 }
 public void ParseEmptyArgsWillReturnCorrectResult()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     var sut = fixture.CreateAnonymous<CurrencyParser>();
     // Exercise system
     var result = sut.Parse(Enumerable.Empty<string>());
     // Verify outcome
     Assert.IsInstanceOfType(result, typeof(HelpCommand));
     // Teardown
 }
 public void ResolveCurrencyParserWillReturnInstance()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     var sut = fixture.CreateAnonymous<CurrencyContainer>();
     // Exercise system
     CurrencyParser result = sut.ResolveCurrencyParser();
     // Verify outcome
     Assert.IsNotNull(result, "ResolveCurrencyParser");
     // Teardown
 }
 public void ParseNullWillReturnCorrectResult()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     var sut = fixture.CreateAnonymous<CurrencyParser>();
     // Exercise system
     ICommand result = sut.Parse(null);
     // Verify outcome
     Assert.IsInstanceOfType(result, typeof(HelpCommand));
     // Teardown
 }
 public void RateIsCorrect()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     var expectedRate = fixture.Freeze<decimal>();
     var sut = fixture.CreateAnonymous<CurrencyUpdateCommand>();
     // Exercise system
     decimal result = sut.Rate;
     // Verify outcome
     Assert.AreEqual(expectedRate, result, "Rate");
     // Teardown
 }
 public void DestinationCodeIsCorrect()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     var expectedCode = fixture.Freeze("Code");
     var sut = fixture.CreateAnonymous<CurrencyUpdateCommand>();
     // Exercise system
     string result = sut.DestinationCode;
     // Verify outcome
     Assert.AreEqual(expectedCode, result, "DestinationCode");
     // Teardown
 }
 public void CurrencyIsCorrect()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     var expectedCurrencty = fixture.Freeze<Currency>();
     var sut = fixture.CreateAnonymous<CurrencyUpdateCommand>();
     // Exercise system
     Currency result = sut.Currency;
     // Verify outcome
     Assert.AreEqual(expectedCurrencty, result, "Currency");
     // Teardown
 }
 public void ParseThreeInvalidArgsWillReturnCorrectResult()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     var args = fixture.CreateMany<string>().ToList();
     var sut = fixture.CreateAnonymous<CurrencyParser>();
     // Exercise system
     var result = sut.Parse(args);
     // Verify outcome
     Assert.IsInstanceOfType(result, typeof(HelpCommand));
     // Teardown
 }
 public void ParseSingleArgWillReturnCorrectResult()
 {
     // Fixture setup
     var fixture = new CurrencyFixture();
     var arg = "DKK";
     var sut = fixture.CreateAnonymous<CurrencyParser>();
     // Exercise system
     var result = sut.Parse(new[] { arg });
     // Verify outcome
     Assert.IsInstanceOfType(result, typeof(HelpCommand));
     // Teardown
 }
        public void ExecuteWillUpdateCurrency()
        {
            // Fixture setup
            var fixture = new CurrencyFixture();

            var currencyMock = fixture.FreezeMoq<Currency>();

            var sut = fixture.CreateAnonymous<CurrencyUpdateCommand>();
            // Exercise system
            sut.Execute();
            // Verify outcome
            currencyMock.Verify(c => c.UpdateExchangeRate(sut.DestinationCode, sut.Rate));
            // Teardown
        }
Ejemplo n.º 11
0
        public void ExecuteWillWriteCorrectOutput()
        {
            // Fixture setup
            var fixture = new CurrencyFixture();
            var expectedOutput = "Usage: UpdateCurrency <DKK | EUR | USD> <DKK | EUR | USD> <rate>." + Environment.NewLine;

            var sut = fixture.CreateAnonymous<HelpCommand>();

            using (var sw = new StringWriter())
            {
                Console.SetOut(sw);
                // Exercise system
                sut.Execute();
                // Verify outcome
                Assert.AreEqual(expectedOutput, sw.ToString(), "Execute");
                // Teardown
            }
        }
        public void ExecuteWillWriteCorrectOutput()
        {
            // Fixture setup
            var fixture = new CurrencyFixture();

            fixture.FreezeMoq<Currency>().SetupGet(c => c.Code).Returns(fixture.CreateAnonymous("Code"));

            var sut = fixture.CreateAnonymous<CurrencyUpdateCommand>();
            var expectedOutput = string.Format("Updated: 1 {0} in {1} = {2}.{3}", sut.DestinationCode, sut.Currency.Code, sut.Rate, Environment.NewLine);

            using (var sw = new StringWriter())
            {
                Console.SetOut(sw);
                // Exercise system
                sut.Execute();
                // Verify outcome
                Assert.AreEqual(expectedOutput, sw.ToString(), "Execute");
                // Teardown
            }
        }
Ejemplo n.º 13
0
        public void ParseValidArgsWillReturnCorrectResult()
        {
            // Fixture setup
            var fixture = new CurrencyFixture();
                        
            var rate = fixture.CreateAnonymous<decimal>();

            var srcCurrencyArg = "EUR";
            var destCurrencyArg = "USD";
            var rateArg = rate.ToString();

            var currencyStub = fixture.CreateMoq<Currency>();
            currencyStub.Setup(c => c.Code).Returns(srcCurrencyArg);

            fixture.FreezeMoq<CurrencyProvider>().Setup(cp => cp.GetCurrency(srcCurrencyArg)).Returns(currencyStub.Object);

            var expectedResult = new Likeness<CurrencyUpdateCommand, CurrencyUpdateCommand>(new CurrencyUpdateCommand(currencyStub.Object, destCurrencyArg, rate));

            var sut = fixture.CreateAnonymous<CurrencyParser>();
            // Exercise system
            var result = sut.Parse(new[] { destCurrencyArg, srcCurrencyArg, rateArg });
            // Verify outcome
            Assert.AreEqual(expectedResult, result, "Parse");
            // Teardown
        }