Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using Moq;
- using RecordStore.Data;
- using RecordStore.Data.Models;
- using RecordStore.Services.Contracts;
- using RecordStore.Services.DTO;
- using RecordStore.Services.Mappers;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace RecordStore.Services.Tests.ArtistServiceTests
- {
- [TestClass]
- public class GetArtist_Should
- {
- [TestMethod]
- public void GetCorrectArtist()
- {
- var options = TestUtils.GetOptions(nameof(GetCorrectArtist));
- var artist = new Artist
- {
- Id = 1,
- Name = "TestArtist",
- Bio = "TestBio"
- };
- var artistDto = new ArtistDTO
- {
- Id = 1,
- Name = "TestArtist",
- Bio = "TestBio"
- };
- var mockSongService = new Mock<ISongService>();
- var mockMapper = new Mock<IDTOMapper<Artist, ArtistDTO>>();
- mockMapper.Setup(x => x.MapFromEntityToDTO(It.IsAny<Artist>())).Returns(artistDto);
- using (var arrangeContext = new RecordStoreContext(options))
- {
- arrangeContext.Add(artist);
- arrangeContext.SaveChanges();
- }
- //Act & Assert
- using (var assertContext = new RecordStoreContext(options))
- {
- var sut = new ArtistService(assertContext, mockSongService.Object, mockMapper.Object);
- var result = sut.GetArtist(1);
- Assert.AreEqual(artist.Id, result.Id);
- Assert.AreEqual(artist.Name, result.Name);
- Assert.AreEqual(artist.Bio, result.Bio);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment