public void ShouldCannotRegisterDuplicateShares() { var sharesTableRepository = Substitute.For <ISharesTableRepository>(); SharesService sharesService = new SharesService(sharesTableRepository); SharesRegistrationInfo args = new SharesRegistrationInfo(); args.Name = "AAPL"; args.Price = 201; sharesService.RegisterNewShares(args); sharesTableRepository.Contains(Arg.Is <SharesEntity>(w => w.Name == args.Name && w.Price == args.Price)).Returns(true); sharesService.RegisterNewShares(args); }
public void ShouldRegisterNewShares() { var sharesTableRepository = Substitute.For <ISharesTableRepository>(); SharesService sharesService = new SharesService(sharesTableRepository); SharesRegistrationInfo args = new SharesRegistrationInfo(); args.Name = "AAPL"; args.Price = 201; var SharesId = sharesService.RegisterNewShares(args); sharesTableRepository.Received(1).Add(Arg.Is <SharesEntity>(w => w.Name == args.Name && w.Price == args.Price)); sharesTableRepository.Received(1).SaveChanges(); }