                                     object: player.currentItem
                                 )
                                 
-                                expect(avfoundationPlayback.droppedFrames).toEventually(equal(5))
+                                expect(avFoundationPlayback.droppedFrames).toEventually(equal(5))
                             }
                             
                             context("when value is negative") {
                                 it("doesn't change the droppedFrames accumulated value") {
-                                    let avfoundationPlayback = AVFoundationPlayback(options: [:])
-                                    avfoundationPlayback.render()
-                                    let accessLog = AccessLogEventMock()
                                     accessLog.setDroppedFrames(31)
                                     let player = PlayerMock(accessLogEvent: accessLog)
-                                    avfoundationPlayback.player = player
+                                    avFoundationPlayback.player = player
                                     
                                     NotificationCenter.default.post(
                                         name: .AVPlayerItemNewAccessLogEntry,

                
                context("with new observedBitrate value") {
                    it("changes the bandwidth") {
                        let avfoundationPlayback = AVFoundationPlayback(options: [:])
                        avfoundationPlayback.render()
                        let accessLog = AccessLogEventMock()
                        accessLog.setObservedBitrate(13.0)
                        let player = PlayerMock(accessLogEvent: accessLog)
                        avfoundationPlayback.player = player

                        NotificationCenter.default.post(
                            name: .AVPlayerItemNewAccessLogEntry,
                            object: player.currentItem
                        )

                        expect(avfoundationPlayback.bandwidth).toEventually(equal(13.0))
                    }
                }

                describe("droppedFrames") {
                    context("with new numberOfDroppedVideoFrames value") {
                        it("changes the droppedFrames") {
                            let avfoundationPlayback = AVFoundationPlayback(options: [:])
                            avfoundationPlayback.render()
                            let accessLog = AccessLogEventMock()
                            accessLog.setDroppedFrames(2)
                            let player = PlayerMock(accessLogEvent: accessLog)
                            avfoundationPlayback.player = player
                            
                            NotificationCenter.default.post(
                                name: .AVPlayerItemNewAccessLogEntry,
                                object: player.currentItem
                            )
                            
                            expect(avfoundationPlayback.droppedFrames).toEventually(equal(2))
                        }
                        
                        context("when occurs another AVPlayerItemNewAccessLogEntry event") {
                            it("changes the droppedFrames to an accumulated value") {
                                let avfoundationPlayback = AVFoundationPlayback(options: [:])
                                avfoundationPlayback.render()
                                let accessLog = AccessLogEventMock()
                                accessLog.setDroppedFrames(2)
                                let player = PlayerMock(accessLogEvent: accessLog)
                                avfoundationPlayback.player = player
                                
                                NotificationCenter.default.post(
                                    name: .AVPlayerItemNewAccessLogEntry,

class AVFoundationPlaybackQualityMetricsTests: QuickSpec {
    override func spec() {
        describe(".AVFoundationPlaybackQualityMetricsTests") {
            
            var avFoundationPlayback: AVFoundationPlayback!
            var accessLog: AccessLogEventMock!
            
            context("when receives AVPlayerItemNewAccessLogEntry event") {
                
                beforeEach {
                    avFoundationPlayback = AVFoundationPlayback(options: [:])
                    avFoundationPlayback.render()
                    accessLog = AccessLogEventMock()
                }
                
                context("with new indicatedBitrate value") {
                    it("changes the bitrate") {
                        let baseObject = BaseObject()
                        var bitrate: Double?
                        let player = PlayerMock(accessLogEvent: accessLog)
                        accessLog.setIndicatedBitrate(7)
                        avFoundationPlayback.player = player
                        baseObject.listenToOnce(avFoundationPlayback, eventName: Event.didUpdateBitrate.rawValue) { userInfo in
                            bitrate = userInfo?["bitrate"] as? Double
                        }

                        avFoundationPlayback.onAccessLogEntry(notification: nil)
                        
                        expect(bitrate).toEventually(equal(7))
                    }
