Esempio n. 1
0
        public void Register_Task_Succesful()
        {
            var            mapperMock      = new Mock <IMapper>();
            var            accountMock     = ACCOUNTS.AsQueryable().BuildMockDbSet();
            DbContextStub  dbContextStub   = new DbContextStub(accountMock.Object);
            AccountService objectUnderTest = new AccountService(dbContextStub, mapperMock.Object);

            var testData = new RegisterDto
            {
                Username = "******",
                Password = "******"
            };

            var result = objectUnderTest.Register(testData).IsCompleted;

            Assert.IsTrue(result);
        }
Esempio n. 2
0
        public void Create_FailsWithEmptyDownloadUrl()
        {
            var           mapperMock      = new Mock <IMapper>();
            var           ticketMock      = TICKETS.AsQueryable().BuildMockDbSet();
            var           accountMock     = ACCOUNTS.AsQueryable().BuildMockDbSet();
            DbContextStub dbContextStub   = new DbContextStub(accountMock.Object, ticketMock.Object);
            TicketService objectUnderTest = new TicketService(dbContextStub, mapperMock.Object);

            var testData = new TicketDto
            {
                Username       = "******",
                Description    = "lorem ipsum",
                Severity       = 3,
                Sha256Checksum = "testtest123",
                Solved         = false
            };

            Assert.IsTrue(ValidateModel(testData).Any(v => v.MemberNames.Contains("DownloadUrl") && v.ErrorMessage.Contains("required")));
        }
Esempio n. 3
0
        public void Delete_Success()
        {
            var           mapperMock      = new Mock <IMapper>();
            var           ticketMock      = TICKETS.AsQueryable().BuildMockDbSet();
            var           accountMock     = ACCOUNTS.AsQueryable().BuildMockDbSet();
            DbContextStub dbContextStub   = new DbContextStub(accountMock.Object, ticketMock.Object);
            TicketService objectUnderTest = new TicketService(dbContextStub, mapperMock.Object);

            var testData = new TicketDto
            {
                Username       = "******",
                Description    = "lorem ipsum",
                DownloadUrl    = "test.pl",
                Severity       = 3,
                Sha256Checksum = "testtest123",
                Solved         = false
            };
            var idToDelete = objectUnderTest.Create(testData).Result;
            var result     = objectUnderTest.Delete(idToDelete).Result;

            Assert.IsTrue(result);
        }