Ejemplo n.º 1
0
        public void JoinPerformerToFile_MultiplePerformersAndFiles_AddsToJoinTable()
        {
            string dbLocation = @"c:\temp\Files on Dvd.accdb";
            PerformerRepository repository = new PerformerRepository(dbLocation);

            List <PerformerFilenameJoinDto> joins = new List <PerformerFilenameJoinDto>()
            {
                new PerformerFilenameJoinDto()
                {
                    PerformerId = 1281, FilenameId = 4115
                },
                new PerformerFilenameJoinDto()
                {
                    PerformerId = 1281, FilenameId = 4116
                },
                new PerformerFilenameJoinDto()
                {
                    PerformerId = 1281, FilenameId = 4117
                },
                new PerformerFilenameJoinDto()
                {
                    PerformerId = 1281, FilenameId = 4118
                },
                new PerformerFilenameJoinDto()
                {
                    PerformerId = 1281, FilenameId = 4119
                },
            };

            repository.JoinPerformerToFile(joins);

            Console.WriteLine("Debug this line");
        }
Ejemplo n.º 2
0
        public void Should_GetNextId_When_HavePerformerRepository()
        {
            var mockedContext = new Mock <IDynamoDBContext>();
            var performerRepo = new PerformerRepository(mockedContext.Object);
            var nextId        = typeof(PerformerRepository).GetMethod(
                "NextKey",
                BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.NonPublic
                );

            Assert.NotNull(nextId);
            Assert.IsType <Guid>(nextId?.Invoke(performerRepo, new object[0]));
        }
Ejemplo n.º 3
0
        public void JoinPerformerToFile_PerformerAndFileExist_AddsToJoinTable()
        {
            string dbLocation = @"c:\temp\Files on Dvd.accdb";
            PerformerRepository repository = new PerformerRepository(dbLocation);

            string performerNameToFind  = "steve austin";
            var    performer            = repository.Get(performerNameToFind);
            int    filenameIdToJoinWith = 2;

            repository.JoinPerformerToFile(performer.Id, filenameIdToJoinWith);

            Console.WriteLine("Debug this line");
        }
Ejemplo n.º 4
0
        public void Add_NewPerformer_AddsToPerformersTable()
        {
            string dbLocation = @"c:\temp\Files on Dvd.accdb";
            PerformerRepository repository = new PerformerRepository(dbLocation);

            PerformerLocalDto performer = new PerformerLocalDto()
            {
                Name = "Jumpin' Jack Flash"
            };

            repository.Add(performer);

            Console.WriteLine("Debug this line");
        }
Ejemplo n.º 5
0
        public async Task Should_Get_Entity_When_ReadEntityAsync()
        {
            var performerId = Guid.NewGuid();

            var mockedContextMock = new Mock <IDynamoDBContext>();

            mockedContextMock.Setup(ctx =>
                                    ctx.LoadAsync <PerformerEntity>(It.IsAny <Guid>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new PerformerEntity()
            {
                Id            = performerId,
                Name          = "Origin",
                Introduction  = "Origin",
                IsDeleted     = false,
                CreatedAt     = DateTime.Today.AddDays(-2),
                UpdatedAt     = DateTime.Today.AddDays(-1),
                VersionNumber = 2
            });
            mockedContextMock.Setup(ctx =>
                                    ctx.SaveAsync(It.IsAny <PerformerEntity>(), It.IsAny <CancellationToken>()))
            .Verifiable();
            var mockedRepository = new PerformerRepository(mockedContextMock.Object);
            var entity           = await mockedRepository.UpdateEntityAsync(Guid.NewGuid(), new PerformerEntity()
            {
                Id            = Guid.NewGuid(),
                Name          = "Mocked",
                Introduction  = "Mocked",
                IsDeleted     = false,
                CreatedAt     = DateTime.Today.AddDays(-1),
                UpdatedAt     = DateTime.Today,
                VersionNumber = 2
            });

            mockedContextMock.Verify();
            Assert.NotNull(entity);
            Assert.Equal(performerId, entity.Id);
            Assert.Equal("Mocked", entity.Name);
            Assert.Equal("Mocked", entity.Introduction);
            Assert.Equal(DateTime.Today.AddDays(-1), entity.CreatedAt);
            Assert.InRange(entity.UpdatedAt, DateTime.Today.ToUniversalTime(), DateTime.Now);
            Assert.Equal(2, entity.VersionNumber);

            var entity2 = await mockedRepository.DeleteEntityAsync(performerId, false);

            mockedContextMock.Verify();
            Assert.NotNull(entity2);
            Assert.True(entity2.IsDeleted);
            Assert.InRange(entity.UpdatedAt, DateTime.Today.ToUniversalTime(), DateTime.Now);
        }
Ejemplo n.º 6
0
        public void Get_ByName_PerformerDoesNotExist_ReturnsPerformer()
        {
            string dbLocation = @"c:\temp\Files on Dvd.accdb";
            PerformerRepository repository = new PerformerRepository(dbLocation);
            PerformerLocalDto   expected   = new PerformerLocalDto()
            {
                Id   = -1,
                Name = "Oscar the Grouch"
            };

            string performerNameToFind = "oscar the grouch";

            var result = repository.Get(performerNameToFind);

            Assert.AreEqual(expected.Id, result.Id);
        }
Ejemplo n.º 7
0
        public void Get_ByName_PerformerExists_ReturnsPerformer()
        {
            string dbLocation = @"c:\temp\Files on Dvd.accdb";
            PerformerRepository repository = new PerformerRepository(dbLocation);
            PerformerLocalDto   expected   = new PerformerLocalDto()
            {
                Id   = 177,
                Name = "Steve Austin"
            };

            string performerNameToFind = "steve austin";

            var result = repository.Get(performerNameToFind);

            Assert.AreEqual(expected.Id, result.Id);
        }
Ejemplo n.º 8
0
        public void Get_GetAllPerformers_ReturnsAllPerformers()
        {
            string dbLocation = @"c:\temp\Files on Dvd.accdb";
            PerformerRepository repository = new PerformerRepository(dbLocation);
            PerformerLocalDto   expected   = new PerformerLocalDto()
            {
                Id   = 177,
                Name = "Steve Austin"
            };

            List <PerformerLocalDto> performersInDb = repository.Get();

            var result = performersInDb.FirstOrDefault(p => p.Name.ToLower() == "steve austin");

            Assert.AreEqual(expected.Id, result.Id);
        }
Ejemplo n.º 9
0
        public void Get_ByName_AliasIsUsed_ReturnsPerformer()
        {
            string dbLocation = @"c:\temp\Files on Dvd.accdb";
            PerformerRepository repository = new PerformerRepository(dbLocation);
            PerformerLocalDto   expected   = new PerformerLocalDto()
            {
                Id   = 177,
                Name = "Steve Austin"
            };

            string performerNameToFind = "chilly mcfreeze";

            var result = repository.Get(performerNameToFind);

            Console.WriteLine("Breakpoint this line");
            Assert.AreEqual(expected.Id, result.Id);
        }