public void SavingMachineSavesNicsAndHostAddresses() { Machine machine = new Machine(); Database db = new SQLiteDatabase($"./{nameof(SavingMachineSavesNicsAndHostAddresses)}", "CoreRegistryRepository"); db.TryEnsureSchema <Nic>(); ApplicationRegistrationRepository repo = new ApplicationRegistrationRepository() { Database = db }; Nic.LoadAll(repo.Database).Delete(repo.Database); HostAddress.LoadAll(repo.Database).Delete(repo.Database); ApplicationRegistration.Data.Dao.Machine.LoadAll(repo.Database).Delete(repo.Database); machine = machine.Save(repo) as Machine; machine.NetworkInterfaces.Each(n => OutLine(n.PropertiesToString(), ConsoleColor.Cyan)); machine.HostAddresses.Each(h => OutLine(h.PropertiesToString(), ConsoleColor.Blue)); NicCollection nics = Nic.LoadAll(repo.Database); HostAddressCollection hosts = HostAddress.LoadAll(repo.Database); Machine machineAgain = machine.Save(repo) as Machine; Expect.AreEqual(machine.Id, machineAgain.Id, "Id didn't match"); Expect.AreEqual(machine.Uuid, machineAgain.Uuid, "Uuid didn't match"); Expect.AreEqual(machine.Cuid, machineAgain.Cuid, "Cuid didn't match"); NicCollection nicsAgain = Nic.LoadAll(repo.Database); HostAddressCollection hostsAgain = HostAddress.LoadAll(repo.Database); Expect.AreEqual(nics.Count, nicsAgain.Count, "Nic count didn't match"); Expect.AreEqual(hosts.Count, hostsAgain.Count, "Host address count didn't match"); }
public ActionResult Save(Bam.Net.CoreServices.ApplicationRegistration.Data.Dao.HostAddress[] values) { try { HostAddressCollection saver = new HostAddressCollection(); saver.AddRange(values); saver.Save(); return(Json(new { Success = true, Message = "", Dao = "" })); } catch (Exception ex) { return(GetErrorResult(ex)); } }