public void ShouldNotAddShareIfItExists() { var shareTableRepository = Substitute.For <IShareTableRepository>(); ShareServices shareServices = new ShareServices(shareTableRepository); ShareInfo args = new ShareInfo { Name = "Печенюшка", CompanyName = "Nescaffe", Price = 2000 }; shareServices.AddNewShare(args); shareTableRepository.Contains(Arg.Is <ShareEntity>( s => s.Name == args.Name && s.CompanyName == args.CompanyName && s.Price == args.Price)).Returns(true); shareServices.AddNewShare(args); }
public void ShouldAddNewShare() { var shareTableRepository = Substitute.For <IShareTableRepository>(); ShareServices shareServices = new ShareServices(shareTableRepository); ShareInfo args = new ShareInfo { Name = "Печенюшка", CompanyName = "Nescaffe", Price = 2000 }; int shareId = shareServices.AddNewShare(args); shareTableRepository.Received(1).Add(Arg.Is <ShareEntity>( s => s.Name == args.Name && s.CompanyName == args.CompanyName && s.Price == args.Price)); shareTableRepository.Received(1).SaveChanges(); }