Exemplo n.º 1
0
        public void RechercherParNom_WithTwoColleaguesWithThisName_ShouldReturnTwoMatricules()
        {
            // Arrange
            var collegue1 = new Collegue(Guid.NewGuid().ToString(), "Dupuis", "Jean", "*****@*****.**", new DateTime(1980, 1, 18), new Uri("https://img.huffingtonpost.com/asset/5901e5881400002000a9c22f.jpeg?ops=scalefit_720_noupscale"));

            var collegue2 = new Collegue(Guid.NewGuid().ToString(), "Durand", "Bernard", "*****@*****.**", new DateTime(1982, 11, 23), new Uri("https://secure.i.telegraph.co.uk/multimedia/archive/03127/terry_crews_3127762b.jpg"));

            var collegue3 = new Collegue(Guid.NewGuid().ToString(), "Dupuis", "John", "*****@*****.**", new DateTime(1984, 8, 2), new Uri("https://secure.i.telegraph.co.uk/multimedia/archive/03029/Becks1_5_3029072b.jpg"));

            var collegueRepositoryMock = Mock.Of <ICollegueRepository>();

            Mock.Get(collegueRepositoryMock)
            .Setup(c => c.GetColleagueMatriculesByNomAsync("Dupuis"))
            .Returns(Task.FromResult((IEnumerable <string>) new List <string> {
                collegue1.Matricule, collegue3.Matricule
            }));

            var collegueService = new CollegueService(_mapper, collegueRepositoryMock);

            // Act
            var result = collegueService.RechercherParNom("Dupuis");

            // Assert
            result.Should().Equals(new List <string> {
                collegue1.Matricule, collegue3.Matricule
            });
        }
Exemplo n.º 2
0
        public void AjouterUnCollegue_WhenColleagueInfosAreValid_ShouldNotThrowException()
        {
            // Arrange
            var collegueDto = new ColleguePostDto("Dupuis", "Jean", "*****@*****.**", new DateTime(1980, 1, 18), new Uri("https://img.huffingtonpost.com/asset/5901e5881400002000a9c22f.jpeg?ops=scalefit_720_noupscale"));

            var collegue = new Collegue(null, "Dupuis", "Jean", "*****@*****.**", new DateTime(1980, 1, 18), new Uri("https://img.huffingtonpost.com/asset/5901e5881400002000a9c22f.jpeg?ops=scalefit_720_noupscale"));

            var collegueRepositoryMock = Mock.Of <ICollegueRepository>();

            var collegueServiceMock = Mock.Of <ICollegueService>();

            Mock.Get(collegueRepositoryMock)
            .Setup(c => c.SaveColleagueAsync(It.IsAny <Collegue>()))
            .Returns(Task.FromResult(1));

            Mock.Get(collegueServiceMock)
            .Setup(c => c.RechercherParMatricule(It.IsAny <string>()))
            .Returns(Task.FromResult(collegue));

            var collegueService = new CollegueService(_mapper, collegueRepositoryMock);

            // Act
            var result = collegueService.AjouterUnCollegue(collegueDto);

            // Assert (no exception)
        }
Exemplo n.º 3
0
 //add a collegue
 public static int AddCollegue(Collegue collegue)
 {
     using (var conn = new SQLiteConnection(FullColleguePath))
     {
         return(conn.Insert(collegue));
     }
 }
Exemplo n.º 4
0
 //remove a collegue
 public static int RemoveCollegue(Collegue collegue)
 {
     using (var conn = new SQLiteConnection(FullColleguePath))
     {
         return(conn.Delete(collegue));
     }
 }
 public async Task <int> SaveColleagueAsync(Collegue collegue)
 {
     _colleguesContext.Collegues.Add(collegue);
     return(await _colleguesContext
            .SaveChangesAsync()
            .ConfigureAwait(false));
 }
Exemplo n.º 6
0
 public override void Say(string message, Collegue collegue)
 {
     if (collegue == Jon)
     {
         James.HandleNotification(message);
     }
     else
     {
         Jon.HandleNotification(message);
     }
 }
 public override void Send(string msg, Collegue collegue)
 {
     if (collegue == Farmer)
     {
         Cannery.MakeKetchup(msg);
     }
     else if (collegue == Cannery)
     {
         Shop.SellKetchup(msg);
     }
 }
Exemplo n.º 8
0
 public override void Send(string message, Collegue collegue)
 {
     if (Collegue1 == collegue)
     {
         Collegue2.Notify(message);
     }
     else
     {
         Collegue1.Notify(message);
     }
 }
        public CollegueService(IMapper mapper)
        {
            _mapper = mapper;
            var collegue1 = new Collegue(Guid.NewGuid(), "bobby", "bob", "*****@*****.**", DateTime.Now, new Uri("http://photo.fr"));
            var collegue2 = new Collegue(Guid.NewGuid(), "tommy", "tom", "*****@*****.**", DateTime.Now, new Uri("http://photo.fr"));
            var collegue3 = new Collegue(Guid.NewGuid(), "poppy", "pop", "*****@*****.**", DateTime.Now, new Uri("http://photo.fr"));
            var collegue4 = new Collegue(Guid.NewGuid(), "rorry", "ror", "*****@*****.**", DateTime.Now, new Uri("http://photo.fr"));

            _data.Add(collegue1.Matricule.ToString(), collegue1);
            _data.Add(collegue2.Matricule.ToString(), collegue2);
            _data.Add(collegue3.Matricule.ToString(), collegue3);
            _data.Add(collegue4.Matricule.ToString(), collegue4);
        }
Exemplo n.º 10
0
 private void Fragment_OnCollegueCreate(object sender, ClosePeopleArgs e)
 {
     if (!e.Name.Equals("") &&
         !e.Description.Equals("") &&
         e.PictureBytes != null &&
         !e.Position.Equals(""))
     {
         Collegue collegue = new Collegue(e.Name, e.Description, e.PictureBytes, e.Position);
         collegue.UserId = userId;
         Data.AddCollegue(collegue);
         adapter.Add(collegue);
         adapter.NotifyDataSetChanged();
     }
     else
     {
         Toast.MakeText(Context, "Трябва да попълните всички полета", ToastLength.Long).Show();
     }
 }
Exemplo n.º 11
0
        public void RechercherParMatricule_WithOneColleagueWithThisMatricule_ShouldReturnOneColleague()
        {
            // Arrange
            var collegue = new Collegue(Guid.NewGuid().ToString(), "Dupuis", "Jean", "*****@*****.**", new DateTime(1980, 1, 18), new Uri("https://img.huffingtonpost.com/asset/5901e5881400002000a9c22f.jpeg?ops=scalefit_720_noupscale"));

            var collegueRepositoryMock = Mock.Of <ICollegueRepository>();

            Mock.Get(collegueRepositoryMock)
            .Setup(c => c.FindColleagueByMatriculeAsync(collegue.Matricule))
            .Returns(Task.FromResult(collegue));

            var collegueService = new CollegueService(_mapper, collegueRepositoryMock);

            // Act
            var result = collegueService.RechercherParMatricule(collegue.Matricule);

            // Assert
            result.Result.Should().Be(collegue);
        }
Exemplo n.º 12
0
        public void WaitForMessage(Socket listener)
        {
            Socket      clientSocket = listener.Accept();
            MapObserver mapObserver  = new MapObserver(clientSocket, map);

            mapObservable.Register(mapObserver);
            Collegue me = new Collegue(snakeId.ToString(), clientSocket);

            mediator.Register(me);
            clients.Add(clientSocket);

            Thread t = new Thread(new ThreadStart(() => WaitForMessage(listener)));

            threads.Add(t);
            t.Start();
            JObject server = new JObject();

            server["serverAddress"] = clientSocket.LocalEndPoint.ToString();
            server["snakeId"]       = snakeId++;
            SendClientMessage(clientSocket, server.ToString());

            Console.WriteLine(String.Format("ClientConnected -> snakeId: {0}, ip: {1}", snakeId - 1, clientSocket.RemoteEndPoint));

            byte[] bytes = new Byte[1024];

            while (true)
            {
                try
                {
                    NetworkStream ns  = new NetworkStream(clientSocket);
                    StreamReader  sw  = new StreamReader(ns);
                    string        dat = sw.ReadLine();

                    JObject dataPairs = JObject.Parse(dat);

                    if (dataPairs.ContainsKey("generatePowerUp"))
                    {
                        map.PowerUps.Add(map.Level.generatePowerUp(map.Height, map.Width));
                    }
                    if (dataPairs.ContainsKey("addSnake"))
                    {
                        map.Snakes.Add(JsonSerializer.Deserialize <SnakeBody>(dataPairs["addSnake"].ToString()));
                    }
                    if (dataPairs.ContainsKey("gameStart"))
                    {
                        map.Level  = LevelFactory.CreateLevel(dataPairs["level"].ToString());
                        map.Width  = map.Width > int.Parse(dataPairs["mapWidth"].ToString()) ? int.Parse(dataPairs["mapWidth"].ToString()) : map.Width;
                        map.Height = map.Height > int.Parse(dataPairs["mapHeight"].ToString()) ? int.Parse(dataPairs["mapHeight"].ToString()) : map.Height;
                    }
                    if (dataPairs.ContainsKey("sayCommand"))
                    {
                        mediator.Send(me.Name, dataPairs["sayCommand"]["to"].ToString(), dataPairs["sayCommand"]["msg"].ToString());
                        Console.WriteLine(dataPairs["sayCommand"]);
                    }
                    else
                    {
                        ProcessData(dataPairs);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    break;
                }
            }
        }
Exemplo n.º 13
0
 public abstract void Send(string message, Collegue collegue);
Exemplo n.º 14
0
 public abstract void Send(string msg, Collegue collegue);