public void TestProperties() { Button expectedClearCoinReturnButton = new Button(); MockCoinReturn expectedCoinReturn = new MockCoinReturn(); MockDialogService expectedDialogService = new MockDialogService(); ClearCoinReturnButtonController clearCoinReturnButtonController = new ClearCoinReturnButtonController(expectedClearCoinReturnButton, expectedCoinReturn, expectedDialogService); Assert.AreSame(expectedCoinReturn, clearCoinReturnButtonController.CoinReturn); Assert.AreSame(expectedClearCoinReturnButton, clearCoinReturnButtonController.Button); Assert.AreSame(expectedDialogService, clearCoinReturnButtonController.DialogService); }
public void TestClickingButtonDoesNotDisplayDialogIfAmountReturnedIsZero() { Button clearCoinReturnButton = new Button(); MockCoinReturn mockCoinReturn = new MockCoinReturn(); MockDialogService mockDialogService = new MockDialogService(); mockCoinReturn.ValueToReturnFromClear = 0; new ClearCoinReturnButtonController(clearCoinReturnButton, mockCoinReturn, mockDialogService); Assert.AreEqual(0, mockDialogService.NumberOfTimesShowMessageWasCalled); clearCoinReturnButton.PerformClick(); Assert.AreEqual(0, mockDialogService.NumberOfTimesShowMessageWasCalled); }
public void TestClickingButtonDisplaysDialogInformingUserOfAmountReturedFromClear(decimal amountReturnedByCoinReturn, string expectedFormatedAmount) { Button clearCoinReturnButton = new Button(); MockCoinReturn mockCoinReturn = new MockCoinReturn(); MockDialogService mockDialogService = new MockDialogService(); mockCoinReturn.ValueToReturnFromClear = amountReturnedByCoinReturn; string expectedDialogText = "You receive: " + expectedFormatedAmount; new ClearCoinReturnButtonController(clearCoinReturnButton, mockCoinReturn, mockDialogService); Assert.AreEqual(0, mockDialogService.NumberOfTimesShowMessageWasCalled); clearCoinReturnButton.PerformClick(); Assert.AreEqual(1, mockDialogService.NumberOfTimesShowMessageWasCalled); Assert.AreEqual(expectedDialogText, mockDialogService.LastMessageShown); }