Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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();
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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");
            }
        }
Ejemplo n.º 7
0
 public Guid AddClient(String name)
 {
     return(_clientsRepository.Add(name));
 }