Esempio n. 1
0
        public void Can_GetAll_Project()
        {
            //Arrange

            var mockRepository = new Mock <IProjectRepository>();

            mockRepository.Setup(m => m.GetAll()).Returns(new[]
            {
                new Project
                {
                    Id     = 1,
                    Name   = "pierwszy",
                    Status = ProjectStatus.Active
                },
                new Project
                {
                    Id     = 2,
                    Name   = "drugi",
                    Status = ProjectStatus.Active
                }
            });
            IGetAllProjects service = new GetAllProjects(mockRepository.Object);

            //Act

            var data = service.Invoke();

            //Assert

            Assert.True(data.Count() == 2);
            Assert.True(data.First().Name == "pierwszy");
        }
Esempio n. 2
0
 public void GetProjetsOf(string key)
 {
     Firebase.FirebaseFirestore.Collection($"projects")
     .OrderBy("date")
     .Get(Source.Default).AddOnCompleteListener(new OnCompleteEventHandleListener(obj =>
     {
         if (obj.IsSuccessful)
         {
             var collectionSnapshot = (QuerySnapshot)obj.Result;
             var list = new List <Projet>();
             collectionSnapshot.Documents.ForEach(d =>
             {
                 var categories = new List <string>();
                 var data       = (Android.Runtime.JavaList)(d.Get("categories"));
                 foreach (var d1 in data)
                 {
                     categories.Add(d1.ToString());
                 }
                 list.Add(new Projet
                 {
                     ProjectId   = d.GetString("projectId"),
                     Date        = DateTime.Parse(d.GetString("date")),
                     Description = d.GetString("description"),
                     Name        = d.GetString("name"),
                     OwnerUId    = d.GetString("ownerUId"),
                     Categories  = categories
                 });
             });
             GetAllProjects.Invoke(this, new ProjectEventArgs
             {
                 ProjectEventArgsType = ProjectEventArgsType.ProjectMine,
                 Projets = list.Where(p => p.OwnerUId == key).ToList()
             });
         }
     }
                                                                                  ));
 }