Beispiel #1
0
        public async Task WithValidObject_GetAllToDoObjects_ReturnsListOfObjects()
        {
            var fakeDb     = A.Fake <IDBInterface>();
            var fakeConfig = A.Fake <IConfiguration>();
            var fakeLogger = A.Fake <ILogger <GetToDoObjectService> >();

            var sut = new GetToDoObjectService(fakeDb, fakeConfig, fakeLogger);

            var toDoEntity1 = new ToDoEntity()
            {
                Description = "My First To Do Object"
            };
            //var toDoEntity2 = new ToDoEntity("userId", "title") { Description = "My Second To Do Object" };

            //A.CallTo(() => fakeDb.ReadAll<ToDoEntity>(A<string>._, A<string>._)).Returns<ToDoEntity>(
            //  new List<ToDoEntity>
            //  {
            //    toDoEntity1,
            //    toDoEntity2
            //  });

            //var toDoObjects = await sut.GetAllToDoObjects();
            //var count = toDoObjects.Count;

            //var toDoDesc1 = toDoObjects[0].Description;
            //var toDoDesc2 = toDoObjects[1].Description;

            //Assert.That(toDoObjects, Is.Not.Null);
            //Assert.That(count, Is.EqualTo(2));
            //Assert.That(toDoDesc1, Is.EqualTo("My First To Do Object"));
            //Assert.That(toDoDesc2, Is.EqualTo("My Second To Do Object"));
        }
Beispiel #2
0
        public void WithExceptionThrown_GetToDoObject_ThrowsException()
        {
            var fakeDb     = A.Fake <IDBInterface>();
            var fakeConfig = A.Fake <IConfiguration>();
            var fakeLogger = A.Fake <ILogger <GetToDoObjectService> >();
            var toDoEntity = new ToDoEntity();

            //A.CallTo(() => fakeDb.Read<ToDoEntity>(A<string>._, A<string>._, A<string>._, A<string>._)).Throws<Exception>();

            var sut = new GetToDoObjectService(fakeDb, fakeConfig, fakeLogger);

            //Assert.That(() => sut.GetToDoObject(toDoEntity).Result, Throws.Exception);
        }