public void ShouldNotAddUserIfItExists() { var userTableRepository = Substitute.For <IUserTableRepository>(); UsersService usersService = new UsersService(userTableRepository); UserInfo args = new UserInfo { Name = "Vasya", SurName = "Pypckin", Balance = 50000, Phone = "88005553535" }; usersService.AddNewUser(args); userTableRepository.Contains(Arg.Is <UserEntity>( u => u.Name == args.Name && u.SurName == args.SurName && u.Balance == args.Balance && u.Phone == args.Phone)).Returns(true); usersService.AddNewUser(args); }
public void ShouldAddNewUser() { var userTableRepository = Substitute.For <IUserTableRepository>(); UsersService usersService = new UsersService(userTableRepository); UserInfo args = new UserInfo { Name = "Vasya", SurName = "Pypckin", Balance = 50000, Phone = "88005553535" }; int userId = usersService.AddNewUser(args); userTableRepository.Received(1).Add(Arg.Is <UserEntity>( u => u.Name == args.Name && u.SurName == args.SurName && u.Balance == args.Balance && u.Phone == args.Phone)); userTableRepository.Received(1).SaveChanges(); }