public override void TestInitialize() { base.TestInitialize(); _appointments = new AppointmentsRepository(); _clients = new ClientsRepository(); _treatments = new TreatmentsRepository(); _technicians = new TechniciansRepository(); _clientData = GetRandom.Object <ClientData>(); var c = new global::Delux.Domain.Client.Client(_clientData); _clients.Add(c).GetAwaiter(); AddRandomClients(); _treatmentData = GetRandom.Object <TreatmentData>(); var tr = new global::Delux.Domain.Treatment.Treatment(_treatmentData); _treatments.Add(tr).GetAwaiter(); AddRandomTreatments(); _technicianData = GetRandom.Object <TechnicianData>(); var te = new global::Delux.Domain.Technician.Technician(_technicianData); _technicians.Add(te).GetAwaiter(); AddRandomTechnicians(); Obj = new TestClass(_appointments, _clients, _treatments, _technicians); }
private void AddRandomClients() { for (var i = 0; i < GetRandom.UInt8(3, 10); i++) { var d = GetRandom.Object <ClientData>(); var c = new global::Delux.Domain.Client.Client(d); _clients.Add(c).GetAwaiter(); } }
public void AClientCanbeAddedInClientRepository() { var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var client = new Client(socket); var clientsRepository = new ClientsRepository(); clientsRepository.Add(client); var clients = clientsRepository.GetClients(); Assert.AreEqual(1, clients.Count); }
public void AcceptCallback(IAsyncResult ar) { acceptEvent.Set(); Socket listener = (Socket)ar.AsyncState; Socket handler = listener.EndAccept(ar); Console.WriteLine(string.Format("Connessione accettata da {0}", handler.RemoteEndPoint)); var client = new Client(handler); _clientsRepository.Add(client); client.BeginReceive(ReadCallback); }
public ActionResult <Client> Post([FromBody] Client client) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _clientsRepository.Add(client); _clientsRepository.SaveChanges(); } catch (Exception ex) { return(BadRequest(_translationService.TranslateException(ex, Request.Headers))); } return(CreatedAtRoute("client", client)); }
private void AddTest() { using (var context = new Context()) { var clientsRepository = new ClientsRepository(context); context.Database.Log = (message) => Debug.WriteLine(message); var userStore = new UserStore <User>(context); var userManager = new ApplicationUserManager(userStore); var randomUser = UserGenerator.GenerateUser(); userManager.Create(randomUser, UserGenerator.RandomString()); _clientDataMock.Client.Projects.First().UserId = randomUser.Id; _clientDataMock.Client.Projects.First().User = randomUser; clientsRepository.Add(_clientDataMock.Client); Assert.AreNotEqual(Guid.Empty, _clientDataMock.ClientId, "Empty guid was return"); } }
public Guid AddClient(String name) { return(_clientsRepository.Add(name)); }