| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using Diligent.WebAPI.Business.Services;
- using Diligent.WebAPI.Data.Entities;
- using FluentAssertions;
- using Microsoft.AspNetCore.Identity;
- using Moq;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Tests
- {
- [TestFixture]
- public class CustomerServiceTest
- {
- private CustomerService service;
-
- [Test]
- public async Task DeleteNotification_WhenUserIsNull_ReturnsFalse()
- {
- // Arrange
- var userManagerMock = new Mock<UserManager<Customer>>(Mock.Of<IUserStore<Customer>>(), null, null, null, null, null, null, null, null);
- userManagerMock.Setup(x => x.FindByIdAsync(It.IsAny<string>())).ReturnsAsync((Customer)null);
-
- service = new CustomerService(userManagerMock.Object);
-
- // Act
- var result = await service.DeleteNotification("", "");
-
- // Assert
- //Assert.IsFalse(result);
- result.Should().BeFalse();
- }
-
- [Test]
- public async Task DeleteNotification_UserIsNotNullAndNotificationIsNull_ReturnsFalse()
- {
- // Arrange
- var userManagerMock = new Mock<UserManager<Customer>>(Mock.Of<IUserStore<Customer>>(), null, null, null, null, null, null, null, null);
- var customer = new Customer
- {
- FirstName = "User",
- LastName = "Someone",
- Notifications = new List<Notification>
- {
- new Notification
- {
- RoomId = "Room1", Count = 1
- }
- }
- };
- userManagerMock.Setup(x => x.FindByIdAsync(It.IsAny<string>())).ReturnsAsync(customer);
-
- service = new CustomerService(userManagerMock.Object);
-
- // Act
- var result = await service.DeleteNotification("arg", "Room1");
-
- // Assert
- result.Should().BeTrue();
- }
- }
- }
|