public void ReturnNull_WhenBandIdIsNull()
        {
            var bandId = Guid.Empty;
            var band   = new Band();

            SingleBandEventArgs eventArg = new SingleBandEventArgs("user id", bandId);

            var viewMock = new Mock <ISingleBandDisplayView>();

            viewMock.Setup(x => x.Model).Returns(new SingleBandDisplayModel());

            var userServiceMock = new Mock <IUserService>();

            var bandServiceMock = new Mock <IBandService>();

            bandServiceMock.Setup(x => x.GetById(bandId)).Returns(band);

            SingleBandDisplayPresenter presenter = new SingleBandDisplayPresenter(
                viewMock.Object,
                userServiceMock.Object,
                bandServiceMock.Object);

            viewMock.Raise(x => x.OnFormGetBand += null, eventArg);

            Assert.That(viewMock.Object.Model.Band, Is.Null);
        }
        public void ReturnAnInstanceOfBand()
        {
            Guid bandId = Guid.NewGuid();
            var  band   = new Band()
            {
                Id = bandId
            };

            SingleBandEventArgs eventArg = new SingleBandEventArgs("user id", bandId);

            var viewMock = new Mock <ISingleBandDisplayView>();

            viewMock.Setup(x => x.Model).Returns(new SingleBandDisplayModel());

            var userServiceMock = new Mock <IUserService>();

            var bandServiceMock = new Mock <IBandService>();

            bandServiceMock.Setup(x => x.GetById(bandId)).Returns(band);

            SingleBandDisplayPresenter presenter = new SingleBandDisplayPresenter(
                viewMock.Object,
                userServiceMock.Object,
                bandServiceMock.Object);

            viewMock.Raise(x => x.OnFormGetBand += null, eventArg);

            Assert.IsInstanceOf <Band>(viewMock.Object.Model.Band);
        }
Example #3
0
        public void CreatesAnInstaceOfPresenter()
        {
            var viewMock        = new Mock <ISingleBandDisplayView>();
            var userServiceMock = new Mock <IUserService>();
            var bandServiceMock = new Mock <IBandService>();

            SingleBandDisplayPresenter presenter = new SingleBandDisplayPresenter(
                viewMock.Object,
                userServiceMock.Object,
                bandServiceMock.Object);

            Assert.That(presenter, Is.InstanceOf <Presenter <ISingleBandDisplayView> >());
        }
Example #4
0
        public void CreatesAnInstance_WhenServices_AreValid()
        {
            var viewMock        = new Mock <ISingleBandDisplayView>();
            var userServiceMock = new Mock <IUserService>();
            var bandServiceMock = new Mock <IBandService>();

            SingleBandDisplayPresenter presenter = new SingleBandDisplayPresenter(
                viewMock.Object,
                userServiceMock.Object,
                bandServiceMock.Object);

            Assert.That(presenter, Is.Not.Null);
        }
Example #5
0
        public void DoesNotThrow_WhenServicesAreValid()
        {
            var viewMock        = new Mock <ISingleBandDisplayView>();
            var userServiceMock = new Mock <IUserService>();
            var bandServiceMock = new Mock <IBandService>();

            Assert.DoesNotThrow(() =>
            {
                SingleBandDisplayPresenter presenter = new SingleBandDisplayPresenter(
                    viewMock.Object,
                    userServiceMock.Object,
                    bandServiceMock.Object);
            });
        }
Example #6
0
        public void ThrowArgumentNullException_WhenBandServiceIsNull()
        {
            var          viewMock        = new Mock <ISingleBandDisplayView>();
            var          userServiceMock = new Mock <IUserService>();
            IBandService bandServiceMock = null;

            Assert.Throws <ArgumentNullException>(() =>
            {
                SingleBandDisplayPresenter presenter = new SingleBandDisplayPresenter(
                    viewMock.Object,
                    userServiceMock.Object,
                    bandServiceMock);
            });
        }
        public void should()
        {
            Guid bandId = Guid.NewGuid();
            Guid userId = Guid.NewGuid();

            User user = new User()
            {
                Id = userId.ToString(), LikedBands = new List <Band>()
            };
            Band band = new Band()
            {
                Id = bandId
            };

            SingleBandEventArgs eventArg = new SingleBandEventArgs(userId.ToString(), bandId);

            var viewMock = new Mock <ISingleBandDisplayView>();

            viewMock.Setup(x => x.Model).Returns(new SingleBandDisplayModel());

            var bandServiceMock = new Mock <IBandService>();

            bandServiceMock.Setup(x => x.GetById(bandId)).Returns(band);

            var userServiceMock = new Mock <IUserService>();

            userServiceMock.Setup(x => x.AddBandToFavorites(userId.ToString(), band));
            userServiceMock.Setup(x => x.GetUserById(userId.ToString())).Returns(user);

            SingleBandDisplayPresenter presenter = new SingleBandDisplayPresenter(
                viewMock.Object,
                userServiceMock.Object,
                bandServiceMock.Object);

            viewMock.Raise(x => x.AddToFavorites += null, eventArg);
        }