예제 #1
0
        public void Result_NoTwoEnvelopesAdded_NotEnoughData()
        {
            CalculatingResult request = CalculatingResult.NotEnoughData;

            Mock <IEnvelopeCreator>      eCreator         = new Mock <IEnvelopeCreator>();
            Mock <IComparer <Envelope> > comparor         = new Mock <IComparer <Envelope> >();
            EnvelopesStorage             envelopesStorage = new EnvelopesStorage(eCreator.Object, comparor.Object);

            CalculatingResult result = envelopesStorage.Result();

            Assert.AreEqual(request, result);
        }
예제 #2
0
        public void Result_NoOneCanBePutToNoOne_NoOne()
        {
            CalculatingResult            request          = CalculatingResult.NoOne;
            Mock <IEnvelopeCreator>      eCreator         = new Mock <IEnvelopeCreator>();
            Mock <IComparer <Envelope> > comparor         = new Mock <IComparer <Envelope> >();
            EnvelopesStorage             envelopesStorage = new EnvelopesStorage(eCreator.Object, comparor.Object);

            envelopesStorage.Envelope1 = new Envelope(2, 2);
            envelopesStorage.Envelope2 = new Envelope(1, 3);

            comparor.Setup(x => x.Compare(It.IsAny <Envelope>(), It.IsAny <Envelope>())).Returns(-1);

            CalculatingResult result = envelopesStorage.Result();

            Assert.AreEqual(result, request);
        }
예제 #3
0
        public void Result_EqualEnvelops_Equal()
        {
            CalculatingResult            request          = CalculatingResult.Equal;
            Mock <IEnvelopeCreator>      eCreator         = new Mock <IEnvelopeCreator>();
            Mock <IComparer <Envelope> > comparor         = new Mock <IComparer <Envelope> >();
            EnvelopesStorage             envelopesStorage = new EnvelopesStorage(eCreator.Object, comparor.Object);

            envelopesStorage.Envelope1 = new Envelope(1, 1);
            envelopesStorage.Envelope2 = new Envelope(1, 1);

            comparor.Setup(x => x.Compare(It.IsAny <Envelope>(), It.IsAny <Envelope>())).Returns(0);

            CalculatingResult result = envelopesStorage.Result();

            Assert.AreEqual(result, request);
        }
예제 #4
0
        public void Result_SeconBiggerThanFirst_FirstToSecond()
        {
            CalculatingResult            request          = CalculatingResult.FirstToSecond;
            Mock <IEnvelopeCreator>      eCreator         = new Mock <IEnvelopeCreator>();
            Mock <IComparer <Envelope> > comparor         = new Mock <IComparer <Envelope> >();
            EnvelopesStorage             envelopesStorage = new EnvelopesStorage(eCreator.Object, comparor.Object);

            envelopesStorage.Envelope1 = new Envelope(1, 1);
            envelopesStorage.Envelope2 = new Envelope(10, 10);

            comparor.Setup(x => x.Compare(It.IsAny <Envelope>(), It.IsAny <Envelope>())).Returns(-1);
            comparor.Setup(x => x.Compare(It.Is <Envelope>(val => val.Equals(envelopesStorage.Envelope2)), It.Is <Envelope>(val => val.Equals(envelopesStorage.Envelope1)))).Returns(1);

            CalculatingResult result = envelopesStorage.Result();

            Assert.AreEqual(result, request);
        }