Beispiel #1
0
        public void GetSharePriceDidntExistTest()
        {
            // Arrange
            var shareRepositoryMock = Substitute.For <ISharesRepository>();

            var sut = new ShareManager(shareRepositoryMock);

            int shareID = 135;

            shareRepositoryMock
            .IsShareExist(Arg.Is <int>(shareID))
            .Returns(false);

            // Act
            sut.GetSharePrice(shareID);

            // Asserts
            shareRepositoryMock.DidNotReceive().GetSharePrice(Arg.Is <int>(shareID));
        }
        public void ShouldGetSharePrice()
        {
            // Arrange
            var shareRepositoryMock = Substitute.For <ISharesRepository>();

            var sut = new ShareManager(shareRepositoryMock);

            int shareID = 135;

            shareRepositoryMock
            .IsShareExist(Arg.Is <int>(shareID))
            .Returns(true);

            // Act
            sut.GetSharePrice(shareID);

            // Asserts
            shareRepositoryMock.Received(1).GetSharePrice(Arg.Is <int>(shareID));
        }