public void ShouldNotRegisterNewShareIfItExists()
        {
            // Arrange
            this.shareTableRepository = Substitute.For <IShareTableRepository>();
            SharesService         sharesService = new SharesService(this.shareTableRepository);
            ShareRegistrationInfo args          = new ShareRegistrationInfo();

            args.CompanyName = "Horns and hooves";
            args.Type        = this.type;
            args.Status      = true;

            // Act
            sharesService.RegisterNewShare(args);

            this.shareTableRepository.Contains(Arg.Is <ShareEntity>( // Now Contains returns true (table contains this share type)
                                                   s => s.CompanyName == args.CompanyName &&
                                                   s.Type == args.Type &&
                                                   s.Status == args.Status)).Returns(true);

            sharesService.RegisterNewShare(args); // Try to reg. same twice and get exception

            // Assert
        }
        public void ShouldRegisterNewShare()
        {
            // Arrange
            this.shareTableRepository = Substitute.For <IShareTableRepository>();
            SharesService         sharesService = new SharesService(this.shareTableRepository);
            ShareRegistrationInfo args          = new ShareRegistrationInfo();

            args.CompanyName = "Horns and hooves";
            args.Type        = this.type;
            args.Status      = true;

            // Act
            var shareId = sharesService.RegisterNewShare(args);

            // Assert
            this.shareTableRepository.Received(1).Add(Arg.Is <ShareEntity>(
                                                          s => s.CompanyName == args.CompanyName &&
                                                          s.Type == args.Type &&
                                                          s.Status == args.Status));
            this.shareTableRepository.Received(1).SaveChanges();
        }