public void Adicionar_Pessoa_Com_Dados_Nulos() { //arrange var pessoa = new Pessoa { Email = "*****@*****.**" }; var repo = new PessoaRepositorio(); //act //repo.AdicionarPessoa(pessoa); var result = repo.BuscarPessoa((x => x.Email == "*****@*****.**")); //assert Assert.NotNull(result); Assert.Equal(pessoa.Email, result.Email); Assert.Equal(pessoa.Nome, result.Nome); }
static void Main(string[] args) { var repo = new PessoaRepositorio(); var pessoa1 = new Pessoa { Email = "*****@*****.**", Nome = "Lucas Marques" }; var pessoa2 = new Pessoa { Email = "*****@*****.**", Nome = "Thiago Roque" }; //repo.AdicionarPessoa(pessoa1); // repo.AdicionarPessoa(pessoa2); var pessoa3 = repo.BuscarPessoa((x => x.Email == "*****@*****.**")); if (pessoa3 != null) { Console.WriteLine(string.Format("Nome: {0} - Email: {1}", pessoa3.Nome, pessoa3.Email)); } Console.ReadLine(); }
public void Adicionar_Pessoa_Sem_SharePoint() { var nomelista = "Pessoas"; using (ShimsContext.Create()) { //arrange var ctx = new ShimClientContext { ExecuteQuery = () => { }, WebGet = () => new ShimWeb { ListsGet = () => new ShimListCollection { GetByTitleString = (s) => { Assert.Equal(nomelista, s); return new ShimList { TitleGet = () => nomelista, AddItemListItemCreationInformation = information => new ShimListItem { Update = () => { //o item foi atualizado Assert.True(true); }, ItemSetStringObject = (s1, o) => { //valida se houve uma inserção do item "Title" //somente Title pode ser inserido //Assert.Equal(s1, "Title"); Assert.NotNull(o); } }, Update = () => { //houve atualizacao Assert.True(true); } }; } } } }; var ctxRuntime = new ShimClientRuntimeContext(ctx); ctxRuntime.LoadOf1M0ExpressionOfFuncOfM0ObjectArray<List>((a, b) => { }); ctxRuntime.LoadQueryOf1ClientObjectCollectionOfM0<List>(delegate { return null; }); ctxRuntime.LoadQueryOf1IQueryableOfM0<List>(delegate { return null; }); ctxRuntime.LoadOf1M0ExpressionOfFuncOfM0ObjectArray<ListItem>((a, b) => { }); ctxRuntime.LoadQueryOf1ClientObjectCollectionOfM0<ListItem>(delegate { return null; }); ctxRuntime.LoadQueryOf1IQueryableOfM0<ListItem>(delegate { return null; }); var repo = new PessoaRepositorio(); //act repo.AdicionarPessoa(new Pessoa{Email = "*****@*****.**", Nome = "lucas"}, ctx); //assert var result = repo.BuscarPessoa((x=> x.Nome == "lucas" )); Assert.NotNull(result); } }