Exemplo n.º 1
0
        public void should_get_empty_list_objects()
        {
            // given
            var api = new Mock <IServerApi>();

            Setup(api);
            var meta = new DMetadata();

            meta.Types.Add(TestTools.RandomMType(23));
            api.Setup(a => a.GetMetadata(0)).Returns(meta);
            var dbInfo        = new DDatabaseInfo();
            var searchFactory = new Mock <ISearchServiceFactory>();
            var backend       = new Mock <IBackend>();
            var service       = new ServerApiService(api.Object, dbInfo, searchFactory.Object, backend.Object);

            // when
            var actual = service.GetObjects(new Guid[0]);

            // then
            Assert.AreEqual(0, actual.Count());

            // when
            var actual2 = service.GetObjects(null);

            // then
            Assert.AreEqual(0, actual2.Count());
        }
Exemplo n.º 2
0
        public void should_get_objects()
        {
            // given
            var api = new Mock <IServerApi>();

            Setup(api);
            var meta = new DMetadata();

            meta.Types.Add(TestTools.RandomMType(23));
            api.Setup(a => a.GetMetadata(0)).Returns(meta);
            var dbInfo        = new DDatabaseInfo();
            var searchFactory = new Mock <ISearchServiceFactory>();
            var backend       = new Mock <IBackend>();
            var service       = new ServerApiService(api.Object, dbInfo, searchFactory.Object, backend.Object);

            var guids = new[]
            {
                Guid.Parse("81C28B67-B8EA-4BA6-9595-40707B47DA8B"),
                Guid.Parse("D029F4C6-4C84-42D5-8C31-A23ECEFCB116")
            };
            var children = new List <DObject>()
            {
                TestTools.RandomDObject(guids[0], 23),
                TestTools.RandomDObject(guids[1], 23)
            };

            api.Setup(a => a.GetObjects(new[] { guids[0], guids[1] })).Returns(children);

            // when
            var actual = service.GetObjects(guids).ToArray();

            // then
            Assert.AreEqual(2, actual.Length);
            Assert.AreEqual(guids[0], actual[0].Id);
            Assert.AreEqual(guids[1], actual[1].Id);
        }