Esempio n. 1
0
        public async Task CreateControlEventAsync_CreatesControlEventAndReturnsIt()
        {
            //arrange
            var(mockRepository, dataBase) = GetMock();
            var service = new ControlEventService(mockRepository.Object);

            //act
            var ce = await service.CreateControlEventAsync(new ControlEvent()
            {
                ControlEventId = 1,
                MaxMark        = 5,
                Date           = "10.01",
                Name           = "lab 1"
            });

            // assert
            // Assert.AreEqual("lab 2", ce.Name);
            Assert.IsTrue(dataBase.ContainsKey(1));
            Assert.IsTrue(dataBase.ContainsValue(ce));

            /*
             * Assert.Pass();
             * Assert.IsTrue();
             * Assert.IsEmpty();
             * Assert.AreEqual();
             * Assert.Throws();
             */
        }
Esempio n. 2
0
        public async Task CreateControlEventAsync_ThrowsExpected(ControlEvent controlEvent,
                                                                 Type type, string message)
        {
            //arrange
            var(mockRepository, dataBase) = GetMock();
            var service = new ControlEventService(mockRepository.Object);

            //act
            var exception = Assert.ThrowsAsync(type, () => service.CreateControlEventAsync(controlEvent));

            // assert
            Assert.AreEqual(message, exception.Message);
            Assert.AreEqual(exception.GetType(), type);
        }