Esempio n. 1
0
        public void ChangeLot_ChangedNameAndComments_NameChangedCommentsNotChanged()
        {
            var lot = new Lot {
                SellerUserId = "*****@*****.**", SellDate = DateTime.Now.AddDays(1), StartDate = DateTime.Now, Name = "Name1", LotComments = new List <LotComment> {
                    new LotComment {
                        Message = "Message1", LotId = 1, UserId = "*****@*****.**"
                    }
                }
            };

            lotOperationsHandler.AddLot(lot, "", "");

            var lotComment = new LotComment {
                Message = "Message2", LotId = 1, UserId = "*****@*****.**"
            };
            var modifiedLot = lotOperationsHandler.GetLot(1);

            modifiedLot.LotComments = new List <LotComment> {
                lotComment
            };
            modifiedLot.Name = "Name2";
            lotOperationsHandler.ChangeLot(1, modifiedLot);

            var resultLot = lotOperationsHandler.GetLot(1);

            resultLot.LotComments = lotCommentOperationsHandler.GetLotComments(1).ToList();

            Assert.AreEqual(1, lotOperationsHandler.GetAllLots().Count());
            Assert.AreEqual(1, resultLot.LotComments.Count());
            Assert.AreEqual("Name2", resultLot.Name);
            Assert.AreEqual("Message1", resultLot.LotComments[0].Message);
        }
        public async Task AddCommentAsync_ValidInput_AddsComment()
        {
            var lot = new Lot {
                SellerUserId = "*****@*****.**", StartDate = DateTime.Now, SellDate = DateTime.Now.AddDays(1), Name = "Name1"
            };
            await lotOperationsHandler.AddLotAsync(lot, "", "");

            var lotComment = new LotComment {
                Message = "Comment1", UserId = "*****@*****.**", LotId = 1
            };
            await lotCommentOperationsHandler.AddCommentAsync(lotComment);

            var lotComment2 = new LotComment {
                Message = "Comment2", UserId = "*****@*****.**", LotId = 1
            };
            await lotCommentOperationsHandler.AddCommentAsync(lotComment2);

            var resultLot = await lotOperationsHandler.GetLotAsync(1);

            resultLot.LotComments = lotCommentOperationsHandler.GetLotComments(resultLot.Id).ToList();
            var resultUser = await userAccountOperationsHandler.GetUserAccountAsync("*****@*****.**");

            resultUser.LotComments = lotCommentOperationsHandler.GetUserComments(resultUser.Email).ToList();

            Assert.AreEqual(1, (await lotOperationsHandler.GetAllLotsAsync()).Count());
            Assert.AreEqual(2, resultLot.LotComments.Count());
            Assert.AreEqual(2, resultUser.LotComments.Count());
            Assert.AreEqual("Comment1", resultLot.LotComments[0].Message);
            Assert.AreEqual("DefaultUser", resultLot.LotComments[0].User.Name);
            Assert.AreEqual("Comment2", resultLot.LotComments[1].Message);
            Assert.AreEqual("DefaultUser", resultLot.LotComments[1].User.Name);
        }