public void testFindById() { repository.deleteAll(); repository.save(new Powder("a")); // id would be generate by database Optional <Powder> powder = repository.findByPowderName("a"); // get id by powder name, suppose that find by powder name works Optional <Powder> p2 = repository.findById(powder.get().Id); // check id is equal or not Assert.AreEqual(powder.get().PowderName, p2.get().PowderName); repository.deleteAll(); Assert.IsFalse(repository.findById(powder.get().Id).isPresent()); }
public Dictionary <string, double> findPowders(string customer, string glass) { Dictionary <string, double> res = new Dictionary <string, double>(); grRepository.findByCustomerAndGlass(customer, glass) .ForEach(gr => { Optional <Powder> powder = powderRepository.findById(gr.PowderId); if (powder.isPresent()) { res.Add(powder.get().PowderName, gr.Weight); } }); return(res); }